Last active
December 22, 2020 17:19
-
-
Save ericelliott/e03558b5d5f8d1c82842f7744a2f3e89 to your computer and use it in GitHub Desktop.
Filter implemented with reduce
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 filter = (fn, arr) => arr.reduce((newArr, item) => { | |
return fn(item) ? newArr.concat([item]) : newArr; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment