Searching a String for a Substring

To determine whether a string is a substring of another, you can use the indexOf() method. For example, the following code writes the string to the console only if it contains the word think:

var myStr = "I think, therefore I am.";
if (myStr.indexOf("think") != -1){
  console.log (myStr);
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.240.252