Knowledgize

.findLast(callbackFn)

Returns the last element in the array that satisfies the provided testing function. If no elements satisfy the testing function, undefined is returned.

Examples:

const numbers = [1, 5, 7, 12, 15, 19]; const lastBigNumber = numbers.findLast(num => num > 10); console.log(lastBigNumber); // 19 const fruits = ['apple', 'banana', 'mango', 'orange', 'raspberry']; const lastFruitWithA = fruits.findLast(fruit => fruit.includes('a')); console.log(lastFruitWithA); // 'raspberry'