String.lastIndexOf
Easy
9
75.0% Acceptance
In this coding challenge, you will be implementing a function called findLastIndexOf(string, substring)
that takes two arguments: a string
and a substring
. The function should return the index of the last occurrence of the value in the string.
Instructions
- If no element is found, return
-1
.
Example test cases
findLastIndexOf('hello world', 'o'); // Output: 7 findLastIndexOf('testing', 't'); // Output: 3 findLastIndexOf('abcdef', 'xyz'); // Output: -1
Hints
- You can use the built-in method
.lastIndexOf()
directly on the input array.