Array.prototype.reduce = function(func,prev){
for(let i = 0 ; i < this.length;i++){
if(prev === undefined){
prev = fn(this[i],this[i+1],i,this)
}else{
prev = fn(prev,this[i],i,this)
}
return prev
}
}
Array.prototype.forEach = function(func){
for(let i = 0 ; i<this.length;i++){
func(this[i],i,this)
}
}
Array.prototype.map = function(func){
let arr = []
for(let i = 0 ; i < this.length;i++){
arr.push(func(this[i],i,this))
}
return arr
}
Array.prototype.some = function(func){
for(let i = 0 ; i < this.length;i++){
if(func(this[i])){
return true
}
}
return false
}
Array.prototype.filter = function(func){
var arr = []
for(let i = 0 ; i <this.length;i++){
if(func(this[i])){
arr.push(this[i])
}
}
return arr
}
Array.prototype.every = function(func){
for(let i = 0 ; i <this.length;i++){
if(!func(this[i])){
return false
}
}
return true
}
Array.prototype.find = function(func){
for(let i = 0 ; i <this.length;i++){
if(func(this[i])) {
return this[i]
}
}
}