how to find characters in a string javascript code example

Example 1: if string javascript

if (typeof myVar === 'string') { /* code */ };

Example 2: How find a specific character in js

var word = "This is how you locate a word in a string";
var n = word.includes("word");

Example 3: find char in string javascript

var str = "Hello world, welcome to the universe.";

var n = str.indexOf("e");

Example 4: js string search

var str = "This is a test sentence";
var hasTest = str.includes("test");

if(hasTest == true){
	//do a thing 
}

Example 5: js check if string contains character

"FooBar".includes("oo"); // true

"FooBar".includes("foo"); // false

"FooBar".includes("oo", 2); // false