Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

findLast Even

Working With Arrayseasy

Course · Section 11: Working With Arrays · Lecture 168: The New findLast and findLastIndex Methods

Implement `lastEven(arr)` returning the last even number, or `null` if there is none, using `findLast`.

Sample tests

Input: lastEven([1,2,3,4,5])
Output: 4
Input: lastEven([1,3])
Output: null

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • find would return the first even, not the last.
Approach & explanation (try first)

findLast returns the last matching element; ?? handles the no-match case.

Loading...
⌘/Ctrl + Enter

Run your code to see results.