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 = ;
arr2 = new Array(...arr1); // my line here <---
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.
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?
I moved your post to a new thread, because your code has nothing to do with solving that problem.
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.