-
-
Save basekays/0685d2b25730766e8801e9b950598f98 to your computer and use it in GitHub Desktop.
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
| /* | |
| _.reduce = function(collection, iterator, accumulator) { | |
| for (var i = 0; i < collection.length; i++) { | |
| accumulator = iterator(accumulator, collection[i]); | |
| } | |
| if (accumulator === undefined) { | |
| return collection[0]; | |
| } | |
| return accumulator; | |
| }; | |
| */ | |
| _.reduce = function(collection, iterator, accumulator) { | |
| if (accumulator === undefined) { | |
| accumulator === collection[0]; | |
| } else { | |
| for (var i = 0; i < collection.length; i++) { | |
| accumulator = iterator(accumulator, collection[i]); | |
| } | |
| } | |
| return accumulator; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment