reduce
Array.prototype.myReduce = function(fn,prev) {
for(let i = 0;i< this.length;i++){
if(typeof prev === 'undefined') {
prev = fn(this[i],this[i+1],i+1,this)
++i;
}else{
prev = fn(prev,this[i],i,this)
}
}
return prev
}
forEach
Array.prototype.myForEach = function(fn){
for(let i = 0;i<this.length;i++){
fn(this[i],i)
}
}
map
Array.prototype.myMap= function(fn){
const arr = []
for(let i = 0;i<this.length;i++){
arr.push( fn(this[i],i))
}
return arr
}