Functional Programming: Implement the filter Method on a Prototype 1

Tell us what’s happening:

Well hint is wrong so I can t pass xd

Your code so far

// The global variable
var s = [23, 65, 98, 5];

Array.prototype.myFilter = function(callback){
// Only change code below this line
var newArray = [];
// Only change code above this line
return newArray;


var new_s = s.myFilter(function(item){
return item % 2 === 1;

Your browser information:

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

Challenge: Implement the filter Method on a Prototype

Link to the challenge:

Thank you, for pointing this out to us.

Do remember, you can ask on the forum, if you have any issue understanding a challenge, or the code to pass the tests.

I will give you a hint:

Use a looping method to go through every element of the specific object called. If an element in the object matches the callback parameter (is true), then push the element to newArray.

Read: Mozilla - Array.prototype.filter

Hope this helps

you can write solution xd

why don’t you try writing it yourself?
if you don’t remember things, google them, go see previous lessons…

i tried same with this functional programming and basic algorithm I don t understand them so no point to keep trying. Once I can see lot of examples than break them down understand them then i can try again.

What do you mean the hit is wrong? Both solutions given under the hints pass the tests for me.

I copied both and I didn t pass.

I passed now but few houes ago no chance.

Good to hear it passed. Sometimes it can also help to log out, clearing the cache and cookies, and then trying again.

Happy coding.

why there is no point?
At least, try to solve them on your own next week. It will show you if you have assimilated the lesson.

magical girl I ve been thinking about javascript and just realized that you could add some tutorials on how to actually use javasript. You know in coding. It would help a lot to connect dots. Since on youtube channel there are only these challenges.

What do you mean with “how to actually use javascript”?
If you need more details, you can search the documentation, like

All the tutorials are offered to the community, by the community. It is all volunteer work. I don’t think requests on tutorials are accepted.

I mean with html and css those kind of things how to make things with them xd.

at this time there is not DOM manipulation with vanilla javascript
but the FrontEnd Frameworks and Libraries will teach about manipulating or creating the html and css

1 Like