Another way to find a string in a string, is by using the lastIndexOf() method, which returns the index of (or location of) the last occurrence of a specified text in a string. In this example, we are looking for the last occurence of the text string locate: