1const string = "javascript";
2const substring = "script";
3
4console.log(string.includes(substring)); //true
1var string = "foo",
2 substring = "oo";
3
4console.log(string.includes(substring));
1const string = "foo";
2const substring = "oo";
3
4console.log(string.includes(substring));
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)
1"FooBar".includes("oo"); // true
2
3"FooBar".includes("foo"); // false
4
5"FooBar".includes("oo", 2); // false