Functional Programming #8: Implement map on a Prototype

Tell us what’s happening:

My solution passes, but I have no idea what a callback is. Any insights welcome.

  **Your code so far**
// The global variable
const s = [23, 65, 98, 5];

Array.prototype.myMap = function(callback) {
const newArray = [];
// Only change code below this line
this.forEach(i => newArray.push(callback(i)));
// Only change code above this line
return newArray;
};

const 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/102.0.5005.61 Safari/537.36

Challenge: Implement map on a Prototype

Link to the challenge:

It’s a function you pass to another function, so that other function can call it.