#Creating a filter function without using .filter

6 messages · Page 1 of 1 (latest)

wheat urchin
#

I'm trying to create a filter function in order to learn how High order functions work under the hood.
I am trying to make filter work but the goal is NOT to use .filter() at all.
Can anyone help?

cunning sleet
#

You're on the right track but went a little off course when you process the result inside the for...

You know that the callback has to return a boolean right? So result will be a boolean... what do you want to do with the current array item (arr[i]) if the result is true? What do you want to do if it's false?

wheat urchin
#

would i need to create a if else statement?

cunning sleet
#

I would say so

wheat urchin
#

@cunning sleet you were right! I was able to get it to work by using an if statement