Functional Programming - Implement the filter Method on a Prototype

Tell us what’s happening:
Describe your issue in detail here.
No Clue what the test wants me to do.

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++) ... failed
  // Only change 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/114.0.0.0 Safari/537.36

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

Link to the challenge:

my new answer also fails

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

3rd question in 8 months…
had to point out how vague the test seems to a noob…
I don’t understand what data I’m iterating through, when it’s in the answer section of the test and not the code…

just lost in this environment.

Thank You, Mr. Dawson

I cheated and looked at the hint… I was missing my if statement … if(this[i],i,this) == true; was what I was missing

my Boolean that filter would normally provide, but I needed to provide using a for loop.

I’m on to the next lesson and having just as much fun. lol.

hope your day is going good!

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