String.prototype.lastIndexOfintermediateconst str = 'abcabc'
str.lastIndexOf('a') // β 3
str.lastIndexOf('z') // β -1
str.lastIndexOf('b', 3) // β 1Use lastIndexOf() to find the index of the last occurrence of a substring, searching from right to left.
Like .indexOf(), .lastIndexOf() is case-sensitive.
Challenge: Implement lastIndexIgnoreCase(str, sub) that searches case-insensitively.
lastIndexIgnoreCase('Hello World Hello', 'hello') // β 12