Functional Programming: Implement map on a Prototype - .myMap

Functional Programming: Implement map on a Prototype - .myMap
0

#1

Write your own Array.prototype.myMap(), which should behave exactly like Array.prototype.map().

How is it that js understands myMap() the same as .map()? Would .yourMap() also work? How does js interpret them as the same?


#2

It will only work the same if you write the code that creates the same functionality.

For example, I should be a to call your myMap method on any array I choose and supply a function of my choosing and your myMap should return the same array as the built-in map method would if supplied with the same array and function.


#3

Thanks
If I read you correctly it’s the format of the function that describes it as the map method?
Does it matter if the word “map” is in the naming or is it just for clarity?


#4

Not sure what you mean by “format”. The code you write must provide the same functionality (result) as the built-in map method.

Strictly for clarity. You can name the method SantaClaus if you want.


#5

Thank you…
I’ll have to read your comments over a few times to let it sink in to my old brain :slight_smile: