// the global Array
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callback) {
var newArray = [];
// Add your code below this line
this.forEach(a => newArray.push(callback(a)));
// Add your code above this line
return newArray;
};
var new_s = s.myMap(function(item) {
return item * 2;
});
The this keyword refers to whatever array the myMap method was used on correct?
And what’s really confusing is on the first line the word callback appears it is written as a parameter. But when it is used inside the myMap declaration, it seems to be used as a function with a passed as a parameter. So is callback a parameter or a function?