Need guidance with (Implement map on a Prototype)

I’m really stuck here i just don’t understand how should i make the newArray as the Argument for the myMap function


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

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

const new_s = s.myMap(function(item) {
return item * 2;
});

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

Challenge: Implement map on a Prototype

Link to the challenge:

u are doing great,but u forgot to wrap the callback around what u are iterating through e.g
newArray.push(callback(s[i]));

1 Like

THANK YOU SO MUCH :pray: :pray:

you are welcome nizar😊

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