Im hoping for some clarification on what this challenge is asking me to do.
**THE TASK: Write your own Array.prototype.myMap(), which should behave exactly like Array.prototype.map(). You should not use the built-in map method. The Array instance can be accessed in the myMap method using this.
I think it is asking me to write a for loop that is equivalent to this line of code:
// 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++) {
}
// 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; rv:106.0) Gecko/20100101 Firefox/106.0
Challenge: Functional Programming - Implement map on a Prototype