Iterate over Arrays with map--Need Help

I need help with this exercise. This is what I have done so far:

var oldArray = [1,2,3,4,5];

// Only change code below this line.

var newArray = oldArray;
var plusThree = {
  return val + 3;


I don’t remember so please someone correct me, but I think maps in JavaScript don’t mutate the existing array, instead they return a new one with the modifications. That way you would save your oldArray variable.

I might be wrong, but it seems that the test for this challenge checks the value of variable newArray specifically. Try assigning your map method with callback function to newArray variable, it works for me.

1 Like

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

look at console.log(plusThree) … when you look at it you will see it produces the required answer …
now delete both console.logs
now if var plusThree is giving correct result … well then why not replace in your code var plusThree and put newArray there …

it will then pass

1 Like