1var str = "We got a poop cleanup on isle 4.";
2if(str.indexOf("poop") !== -1){
3 alert("Not again");
4}
5//use indexOf (it returns position of substring or -1 if not found)
1const pets = ['cat', 'dog', 'bat'];
2
3console.log(pets.includes('cat'));
4// output: true
1const names = ["Mario", "Anna", "Jacob"];
2
3console.log(names.includes("Jade")) // Output: False
4// It Checks If (Names) Contain's ("Jade") Or Not
5
6
7console.log(names.includes("Anna")) // Output: True
8// It Checks If (Names) Contain's ("Anna") Or Not
9
1var string = "foo",
2var substring = "oo";
3
4console.log(string.includes(substring));
1var colors = ['yellow', 'red', 'pink'];
2var string = 'yellow and red are pretty cool';
3
4// outputs false
5console.log(colors.include('blue');
6// outputs true
7console.log(string.includes('yellow');