1const string = "foo";
2const substring = "oo";
3
4console.log(string.includes(substring));
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
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');