freeCodeCamp Challenge Guide: Implement map on a Prototype with for in

I tried to this challange using for in loop. But its not working. What is wrong with my solution? Or can someone explain me how can we do it with for in loop. Thanks.

Array.prototype.myMap = function(callback) {
  const newArray = [];
  // Only change code below this line
    for(let value in this){
      newArray.push ( callback( this[value], value , this))
    }
  // Only change code above this line
  console.log(newArray)
  return newArray;
};


When you use a for...in, the value is a string. It should be a number.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.