Created
April 18, 2017 14:23
-
-
Save dewey92/7abb861ba27fb2d47a0674bb7d91146d 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 filter = (fn, arr) => { | |
const [head, ...tail] = arr | |
if (tail[0] === undefined) return [] | |
if (fn(head)) { | |
return [head, ...filter(fn, tail)] | |
} else { | |
return [...filter(fn, tail)] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment