Copy machine challenge

Copy machine challenge
0

#1

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?


Copy an Array with the Spread Operator (do not know how to turn logic into code)
#2

Can you confirm the url of the challenge for which you are trying to use the above code?

Also, can you post all of your code and not just a single line?


#4

I moved your post to a new thread, because your code has nothing to do with solving that problem.


#6

I thought you needed help with something. If so, edit your last post to display the code and your specific question, so we can get you the help you need.