[SOLVED] How to test if string ends with a list of string


I have an array of string and another string, Is there a simple way to test if my single string ends with one of the strings in the array of strings?

const strings = [

if ('hi, this is a test'.endsWith(...strings)) { // I know that this isn't right but this is the idea
  console.log("String ends with one of the strings !");


How about Array.prototype.some()?

if (strings.some(s => 'hi, this is a test'.endsWith(s))) {...}

Answered By – Robo Robok

Answer Checked By – Marilyn (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *