How to check if a string contains a certain substring?
October 26, 2018
If you have a string foobar
, you can check if it contains the string bar
by doing this:
let some_string = "foobar";
if (some_string.includes("foo")) {
alert("contains it!") ;
}