JSFiddle - React, Tailwind, and code Playground
JavaScript
var str = "Hello World";// For example, lets search this string,
var term = "World";// for the term "World",
var index = str.indexOf(term);// and get its index.
if(index != -1){// If the index is not -1 then the term was matched in the string,
alert(index);// and we can do some work based on that logic.
}