Tell us what’s happening:
Describe your issue in detail here.
Do i type the while loop?
Your code so far
Array.prototype.myFilter = function(callback) {
const newArray = [];
// Only change code below this line
for (let i = 0; i < this.length; i++) {
const result = callback(this[i], i, this);
newArray.push(result);
}
// Only change code above this line
return newArray;
};
const result = [1, 1, 2, 5, 2].myFilter((element, index, array)=> array.indexOf(element) === index);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) 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: