On this challenge here: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place
I need to use the spread operator to copy an array. Here’s my code (my line is commented as such):
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2 = [];
(function() {
"use strict";
arr2 = new Array(...arr1); // my line here <---
})();
console.log(arr2);
This should work (I think) but it’s not accepted. I’m outputting the value of arr2
to the console and it’s correct, but it still says this requirement isn’t being met:
... spread operator was used to duplicate arr1.
Any ideas?