Custom array reduce function
JavaScript
Array.prototype.myReduce = function(fn, acc) {
let index = 0;
if(acc == undefined){
index = 1;
acc = this[0];
}
for(let index = 0; index<this.length; index++) {
acc = fn(this[index], acc);
}
return acc;
}
([11,22,33]).myReduce((acc, val) => (acc + val), 0);