Help Implementing map on a Prototype

Tell us what’s happening:
Pls dont know whats wrong with my code.

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 a = 0; a < this.length; a++){
    newArray.push(this[a]);
  }
  // Add your 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: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0</code>.

**Link to the challenge:**
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype

You are just coping the array in this way

You need to change the values applying the callback function on them, you don’t use the callback function anywhere inside the method

Thank you for the quick response, pls I’m still finding a bit challenging to understand. check the code below if I’m doing it correctly.

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

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

};

var new_s = s.myMap(function(item){
return item * 2;
});

console.log(new_s)

Do you remember how to pass an argument in a function? Hint: not like that

Also, if it was the correct way you would be transforming the value of a not the value in the array - You still need to use the notation to reference the value in the array

Thank u for jugging my memory on how to pass an argument in function exactly what i was missing, i managed to get it to work with your help.

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

Array.prototype.myMap = function(callback){
var newArray = [];
// Add your code below this newArray;

};

var new_s = s.myMap(function(item){
return item * 2line
for (let a = 0; a < this.length; a++){
newArray.push(callback(this[a]));
}
// Add your code above this line
return ;
});

console.log(new_s)