Functional Programming - Implement map on a Prototype

It uses the same callback function on every item of the array

Ok, but what does it use the callback function to accomplish? Why would someone want to use map?

Iterates tho the array and perform the same function on every item. After that, it return the new array

So the purpose of map is to build a new array by calling the fallback on every element of the old array?

Yes, it is. But if i can’t use foreach, then how can i mimic that?

I didn’t say that you cannot use a forEach. Just that the way you stuck forEach and the callback together doesn’t make sense.

What do you need to pass to the callback?

I dunno. Something to make it work, I think

Read above. What did we say map does?

It performs the same callback function on every item of the array, then returns a new one.

Ok, so what should we pass to the callback function?

we pass array? Or the callback function itself? Like what it needs to do?

I’m not sure you’re understanding what map does? You just said above what map does, and that says what needs to be passed to the callback

I don’t understand what needs to be passed to it but I think I get what map does

But you said here what is passed to the callback

The array? The function it needs to perform?

I would go back to the map lesson and read what map does again

I get what it does. But it’s different tho…

The purpose of myMap is identical to map. So the callback needs to do the same thing for both. The map lesson talks about what the callback does and what it’s arguments are.

Everything else isn’t. I understand I need to use for each to perform the same function on every item of the array. But…

myMap is really actually supposed to actually do exactly the same thing as map