JS Built-ins
StringString.prototype.indexOfintermediate

String.prototype.indexOf() β€” fromIndex parameter

πŸ“– Usage Example
const str = 'hello world'
str.indexOf('world')    // β†’ 6
str.indexOf('xyz')      // β†’ -1
str.indexOf('l')        // β†’ 2

Use indexOf() to find the index of the first occurrence of a substring, returning -1 if not found.

String.prototype.indexOf() β€” fromIndex

The optional second argument sets the start position of the search.

Challenge: Implement findAfter(str, sub, from) using .indexOf(sub, from).

findAfter('hello hello', 'hello', 1) // β†’ 6
πŸ’‘ Hints (1)
  • β€’ `str.indexOf(sub, from)` starts scanning at index `from`.