Iterate over Arrays with map #222

Iterate over Arrays with map #222
0.0 0

#1

Tell us what’s happening:

Trying to complete the challenge: Iterate over Arrays with map (#222 in my least), however, i’m stuck.

i’m sure of my code, even when I alter the last variables, switching old with new, it works in theory, but I fail because I alter the original array.

please help!

Your code so far

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

// Only change code below this line.

var newArray = oldArray.map(function(val) {
  
  return val + 3;
  
});


var newArray = oldArray;

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36.

Link to the challenge:


#2

You need to get rid of the last line. In the challenge, you were meant to replace it. Your map function works great and then in the last line you copy over what you did.


#3

Hey man, thanks… I was stuck, I thing i tried commenting it out, but I guess I needed to reset the code or refresh the browser.

I appreciate it!