Answers for "string check contains in js"

89

javascript string contains

var string = "foo",
    substring = "oo";

console.log(string.includes(substring));
Posted by: Guest on December-21-2019
3

javascript string contains

var email = "[email protected]";
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
Posted by: Guest on June-19-2021
0

js string contains

let example = "Example String!";
let ourSubstring = "Example";

if (example.indexOf(ourSubstring) != 0) {
	console.log("The word Example is in the string.");
} else {
	console.log("The word Example is not in the string.");
}
Posted by: Guest on October-12-2021

Code answers related to "string check contains in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language