Implement Map on a Prototype (for me)

Tell us what’s happening:
for the code below:
" for (let i = 0; i < this.length; i++) {

I dont understand why “this” has to be used.
Second, how does “callback” that is “item” from calling
the function know to use the array “s”?
I do not see a correlation or establishing that “item” equals the global array “s” or
“callback” equals global array “s”.
Please help me understand how “callback” or “item” knows to use the global array without the code specifically establishing a correlation.

Your code so far

// the global Array
var s = [23, 65, 98, 5];

Array.prototype.myMap = function(callback){
var newArray = [];
// Add your code below this line
    for (let i = 0; i < this.length; i++) {
// Add your code above this line
return newArray;


var 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/79.0.3945.130 Safari/537.36.

Challenge: Implement map on a Prototype

Link to the challenge:

This adds a new method named myMap to Array’s prototype. The method takes one argument (a function that we have named callback). this in this case refers to actual array upon myMap was called. s is the array. That the myMap method knows which array to use.