Tell us what’s happening:
Describe your issue in detail here.
i couldn’t complete my third test given on this segment. please help me out
Your code so far
Array.prototype.myFilter = function(callback) {
const newArray = [];
// Only change code below this line
this.forEach(a=> {
if(callback(a)){
newArray.push(a)
}
})
// Only change code above this line
return newArray;
};
console.log([23, 65, 98, 5, 13].myFilter(item => item % 2))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Challenge: Functional Programming - Implement the filter Method on a Prototype
Link to the challenge: