JavaScript - Polyfill for reduce()
Anonymous
Array.prototype.myReduce = function(callback, initialValue) { let accumulator = initialValue !== undefined ? initialValue : this[0]; let startIndex = initialValue !== undefined ? 0 : 1; for(let i = startIndex; i < this.length; i++) { accumulator = callback(accumulator, this[i], i, this); } return accumulator; };
Check out your Company Bowl for anonymous work chats.