Functional Programming - Implement the filter Method on a Prototype

Tell us what’s happening:
Describe your issue in detail here.

Your code so far
I got 3 out of 4 correct but it saying myFilter((element, index, array) => array.indexOf(element) === index)should return[1, 2, 5]` .
please help! thanks

Array.prototype.my filter = function(callback) {
  const newArray = [];
  // Only change the code below this line

for (let i = 0; i< this.length; i += 1) {
  if (callback(this[i])) {
    newArray.push(this[i]);
  }
}

  // Only change the code above this line
  return newArray;
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Challenge: Functional Programming - Implement the filter Method on a Prototype

Link to the challenge:

You need to handle the case when three parameters are given to your function.

1 Like

thanks, I’ve solved it :smiley:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.