How to check whether a string contains a substring in JavaScript?

How to check whether a string contains a substring in JavaScript?

There is a includes method

1 Like

You can alternately use the String.indexOf() function to check for substrings.