Implement map on a Prototype 73 version 2

Tell us what’s happening:
Ok, so this is my last attempt, might have to move on and come back to it later, its been probably over 3 weeks @ 20 min per day.

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
  // 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 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

1 Like

Where are you using callback? It is the function that is passed when the method is called, the function that should mutate the elements, and you are not using it anyway

  // Add your code below this line
  this.forEach(a => newArray.push(callback(a)));
  // Add your code above this line

Try this man . it will pass all test case