Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Last active December 22, 2020 17:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ericelliott/e03558b5d5f8d1c82842f7744a2f3e89 to your computer and use it in GitHub Desktop.
Save ericelliott/e03558b5d5f8d1c82842f7744a2f3e89 to your computer and use it in GitHub Desktop.
Filter implemented with reduce
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