Tell us what’s happening:
Describe your issue in detail here.
Could someone please explain why the callback function has 3 parameters (this[I], I, this) initially my code just had 1 parameter for the callback function (this[I]) but I don’t understand why (I, this) are also parameters and what they do
Your code so far
Array.prototype.myMap = function(callback) {
const newArray = [];
// Only change code below this line
for (let i = 0; i < this.length; i++){
newArray.push(callback(this[i], i, this));
}
// Only change code above this line
return newArray;
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15
Challenge: Functional Programming - Implement map on a Prototype
Link to the challenge: