Created
July 20, 2023 22:17
-
-
Save MarkAdell/05afa2f6f873694c21eff85f49a9552d to your computer and use it in GitHub Desktop.
Functional programming article exercise solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findLast(array, predicate) { | |
for (let i = array.length - 1; i >= 0; i--) { | |
if (predicate(array[i])) { | |
return array[i]; | |
} | |
} | |
return undefined; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment