String

String Manipulation

Contains

Check whether the variable has specific sub string with includes keyword.

const string = "foo";
const substring = "oo";

console.log(string.includes(substring));

This works great for array of string data type as well.

let vowelsArr = ["a", "e", "i", "o", "u"];
console.log(vowelsArr.includes("k"));

MDN