Hi, I’m not following the solution presented. I understand the assignment of the spread operator (i.e. between the brackets). What I don’t understand is:
a. the use of the function
b. the use of “use strict”
c. the extra use of parentheses to wrap the function
d. the extra use of parentheses at the end (outside) of the function
Any explanations on each of the above is greatly appreciated.
Your code so far
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
arr2 = [...arr1]; // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36.
Challenge: Use the Spread Operator to Evaluate Arrays In-Place
Well, in this case, I guess mostly readability, and ease of typing. If you want to re-use the value multiple times, make it shorter/consistent. This code is not practical; it serves to show how you might find the use-case.
In this case, the only thing the function is doing is limiting the scope of 'use strict'.