Use the Spread Operator to Evaluate Arrays In-Place- someone help me?

What is the problem my code ?

Your code so far

const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2;
(function() {
  "use strict";
   var arr2 = [...arr1]; // change this line

let numbers = [-12, 160, 0, -3, 51];
let minNum = Math.min(numbers);

Your browser information:

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

Link to the challenge:

Reset the code and only input the spread operator part.

One issue with your code is that arr2 is being assigned a value inside of the func in a way where the result of the assignment wont be recognized outside of the func. This makes arr2 remain undefined outside of the func (scope issue)

Let me know if this helps here

You do not need to declare arr2 inside the function. Just reassign the value. arr2 is meant to be a global variable. When you declare arr2 inside the function, the global variable arr2 (outside the function) retains its’ original value of undefined.

1 Like