Tell us what’s happening:
Describe your issue in detail here.
The ’ Mymap ’ function takes a function as argument. Then it returns a array.
The part I don’t understand is How the array returned by Mymap function is iterated into the function that was the argument of the Mymap function ???
**Your code so far**
// The global Array
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callback) {
var newArray = [];
// Add your code below this line
for (let i = 0; i < this.length; i++) {
newArray.push(callback(this[i]));
}
// Add your 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
Challenge: Implement map on a Prototype
Link to the challenge: