typescript check if string contains code example

Example 1: check for substring javascript

const string = "javascript";
const substring = "script";

console.log(string.includes(substring));  //true

Example 2: string.contains javascript

var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
	alert("Not again");
}

Example 3: typescript string contains

const test = 'Hello World';
if (test.includes('World')) { 
  // Found world
}

Example 4: how to check whether a string contains a substring in typescript online

const string = "foo";
const substring = "oo";

console.log(string.includes(substring));