0

I want to perform the following actions depending on whether the string sample_input consists any of the characters in the array vowel_list.

let vowel_list = ["a", "e", "i", "o", "u"]
let sample_input = "Hello, Stack Overflow!"

// If sample_input has a vowel, I want to print "Great, sample_input has got a vowel in it!" on the console.

I tried to use .includes(), but later on it dawned on me that it could only check whether the string has a specific block of string in it. For instance,

let test = "Hello World!"

if (test.includes("H")) {
    console.log("The string 'test' includes letter H")
}
SenaThenu
  • 1
  • 3
  • 1
    `vowel_list.some(v => sample_input.includes(v);` will return a true if any of the elements of the array are included in the string. – pilchard May 23 '23 at 09:39

0 Answers0