Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JavaScript Array Reduce Function
Array.prototype.reduce = function (fn, init) {
var s = init;
var l = this.length;
for (var i = 0; i < l; i++) {
s = fn(s, this[i]);
}
return s;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.