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
1var str = "We got a poop cleanup on isle 4.";
2if(str.indexOf("poop") !== -1){
3 alert("Not again");
4}
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 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');
1const str = 'To be, or not to be, that is the question.'
2
3console.log(str.includes('To be')) // true
4console.log(str.includes('question')) // true
5console.log(str.includes('nonexistent')) // false
6console.log(str.includes('To be', 1)) // false
7console.log(str.includes('TO BE')) // false
8console.log(str.includes('')) // true