1var string = "foo",
2 substring = "oo";
3
4console.log(string.includes(substring));
1var colors = ["red", "blue", "green"];
2var hasRed = colors.includes("red"); //true
3var hasYellow = colors.includes("yellow"); //false
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 array1 = [1, 2, 3];
2
3console.log(array1.includes(2));
4// expected output: true
5
6const pets = ['cat', 'dog', 'bat'];
7
8console.log(pets.includes('cat'));
9// expected output: true
10
11console.log(pets.includes('at'));
12// expected output: false