Use the includes() method to search for a substring inside a string:
var word = "bravery"; console.log(word.includes(“rave”)); // true
🏋️♂️ Recommended course ⤵Wes Bos' ES6 for Everyone!
This quick and easy way to check if one string contains another is very simple to implement. Just call the method with the substring you’re looking for as the argument:
Remember that the comparison takes cases into consideration:
var burnIntro = “Yo momma ~”; console.log(burnIntro.includes(“yo”)); // false