Created
April 26, 2014 06:39
-
-
Save tan-yuki/11313358 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
_.mixin({ | |
sum: function(list, callback) { | |
return _.reduce(list, function(memo, item) { | |
return memo + callback(item); | |
}, 0); | |
} | |
}); | |
// == test == | |
// _.sum([{price:10}, {price:20}, {price:30}], function(item) { return item.price; }); | |
// > 60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment