Create a polyfill for array reduce
Utilisateur anonyme
Array.prototype.myReduce = function (callback, initialValue) { let accumulator; let firstIndex = 0; if (arguments.length === 1) { accumulator = this[0]; firstIndex = 1; } else { accumulator = initialValue; } for (let i = firstIndex; i < this.length; i++) { accumulator = callback(accumulator, this[i], i, this); } return accumulator; }