// use the variable.includes()
const myString = "hello world!"
if(myString.includes("hello")){
// do something
}else{
//also do something
}
"FooBar".includes("oo"); // true
"FooBar".includes("foo"); // false
"FooBar".includes("oo", 2); // false
var email = "grepper@gmail.com";
if(email.includes("@")){
console.log("Email is valid");
}
else{
console.log("Email is not valid");
}
// includes return boolean, if your string found => true else => false
if (your_string.indexOf('hello') > -1)
{
alert("hello found inside your_string");
}