How to Check Whether a String Contains a Substring in JavaScript?
How to check whether a string contains a substring in JavaScript? let str = “Hello, world!”; let substr = “world”; console.log(str.includes(substr)); // Output: true You can also use the indexOf() method which returns the index of the first occurrence of the substring in the string, or -1 if the substring is not found. Here’s an … Read more