Tell us what’s happening:
Hello dear FCC community
This is my code on which I spend more than five hours but still could not understand it exactly
Until I consoled.log - callback- parameter inside the function in the 3rd line
This could have been much easier to understand if you had added the -callback-
function inside the code
Appreciate your hard work
Thank you
Your code so far
// The global variable
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callback){
var newArray = [];
// Only change code below tis line
this.forEach(function (anything) {
newArray.push(callback(anything))
})
// Only change code above this line
return newArray;
};
var new_s = s.myMap(function(item){
return item * 2;
});
console.log(new_s)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36
.
Challenge: Implement map on a Prototype
Link to the challenge: