JS Built-ins
StringString.prototype.lastIndexOfintermediate

String.prototype.lastIndexOf() β€” case-sensitive

πŸ“– Usage Example
const str = 'abcabc'
str.lastIndexOf('a')    // β†’ 3
str.lastIndexOf('z')    // β†’ -1
str.lastIndexOf('b', 3) // β†’ 1

Use lastIndexOf() to find the index of the last occurrence of a substring, searching from right to left.

String.prototype.lastIndexOf() β€” Case Sensitivity

Like .indexOf(), .lastIndexOf() is case-sensitive.

Challenge: Implement lastIndexIgnoreCase(str, sub) that searches case-insensitively.

lastIndexIgnoreCase('Hello World Hello', 'hello') // β†’ 12
πŸ’‘ Hints (1)
  • β€’ Convert both to lowercase before calling `.lastIndexOf()`.