Tell us what’s happening:
Can someone help me, I really didn’t understand how to do that.
Your code so far
// The global variable
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callback) {
var newArray = [];
// Only change code below this line
newArray.push(this.callback);
// Only change code above this line
return newArray;
};
var new_s = s.myMap(function(item) {
return item * 2;
});
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
So after read in MDN i understand like this:
Map method have parameter, the paramenter iterate every item inside array then send it into new array, without changes the original one.
map takes an array, and returns a new array where each element is changed using the passed in function
you need to make the same
in the method you are writing, the function is called callback and the array this, you need to return a new array with all elements changed using the function