Last active
December 9, 2020 01:57
-
-
Save juliobetta/42cfdaac74de1cac572b78b51ad3a0f1 to your computer and use it in GitHub Desktop.
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
const hasDebutAfter1980 = character => character.debut > 1980; | |
const withFind = characters.find(hasDebutAfter1980); | |
const withReduce = characters.reduce((accumulator, character) => { | |
if(hasDebutAfter1980(character) && !accumulator) { | |
return character; | |
} | |
return accumulator; | |
}, null); | |
// { name: "Donkey Kong", debut: 1981 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment