Last active
March 20, 2017 10:40
-
-
Save mozkoq/c063e57afa6b74d12f3015f4f70acda1 to your computer and use it in GitHub Desktop.
javascript map
This file contains hidden or 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 map = (fn, arr) => { | |
const DEFAULTSTATE = [] | |
return arr.reduce( | |
(result, current, i, reducingArray) => | |
[...result, fn(current, i, reducingArray)], | |
DEFAULTSTATE | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment