Tell us what’s happening:
I have a few questions about the code in this problem:
Can someone explain why we need to assign arr2 = […arr1] inside a blank function? I don’t think I’ve seen an empty function like that before.
Also, what does it mean when we say" let arr2; " — I’ve always seen an expression after a new variable name so I’m confused.
Thanks in advance for help!
Your code so far
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2;
(function() {
"use strict";
arr2 = [...arr1]; // change this line
})();
console.log(arr2);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place/