indexOf < String < JavaScript
The indexOf() of a String searches the string and returns the index of the first occurrence of the specified substring. It takes an optional starting position and returns the first occurrence of the specified substring at an index greater than or equal to the specified number.
const paragraph = "I think Ruth's dog is cuter than your dog!";
const searchTerm = 'dog';
const paragraphIndexDog = paragraph.indexOf(searchTerm);
console.log(paragraphIndexDog);
// 15
const paragraphIndexDog2 = paragraph.indexOf(searchTerm, paragraphIndexDog + 1);
console.log(paragraphIndexDog2);
// 38