Created
December 15, 2013 06:07
-
-
Save cuipengfei/7969526 to your computer and use it in GitHub Desktop.
Implement Map with Reduce
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
module.exports = function arrayMap(arr, fn) { | |
return arr.reduce(function (acc, current) { | |
acc.push(fn(current)) | |
return acc | |
}, []) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment