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++) {
newArray.push(callback(this[i]));
}
// Only change code above this line
return newArray;
};
console.log('test')
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: Functional Programming - Implement map on a Prototype
Link to the challenge: