Functional Programming - Implement map on a Prototype

Tell us what’s happening:
Describe your issue in detail here.
The tests code uses the incorrect parameter for index.
[1, 1, 2, 5, 2].myMap((element, index, array) => array[i + 1] || array[0])
Your code so far

Array.prototype.myMap = function(callback) {
  const newArray = [];
  // Only change code below this line
for (let i = 0; i < this.length; i++) {
  // Only change code above this line
  return newArray;


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Functional Programming - Implement map on a Prototype

Link to the challenge:

the test description has a typo so you can just change the word index to i and you can use it to test your code.

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