Array.prototype.findLastIndexbeginnerconst nums = [1, 3, 7, 2, 5]
nums.findLastIndex(n => n % 2 !== 0) // β 4 (index of last odd)Use findLastIndex() to get the index of the last element satisfying a condition.
Array.prototype.findLastIndex(callback) is the reverse of findIndex(). It iterates from the end and returns the index of the last element for which the callback is truthy, or -1 if not found.
Challenge: Implement lastEvenIndex(nums) that returns the index of the last even number.
lastEvenIndex([1, 2, 3, 4, 5]) // β 3
lastEvenIndex([1, 3, 5]) // β -1