ES6 spread operator answer rejected

Tell us what’s happening:
Describe your issue in detail here.
I wasn’t really sure that the question was or what they expected us to do so I came with a solution that is an overkill, however, it should be correct according to their tests.

The failed test is that I’m not using the spread operator which is not true. I’m using the operator as seen below.

Your code so far


const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2;

arr2 = [].concat(...arr1);  // Change this line

console.log(arr2);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36

Challenge: Use the Spread Operator to Evaluate Arrays In-Place

Link to the challenge:

I think the tests expect the spread operator inside the literal array - it’s difficult to have tests that consider everything that a learner could write

I would also point out that the spread operator doesn’t really do anything there anyway:

console.log([].concat(arr1));
// [ 'JAN', 'FEB', 'MAR', 'APR', 'MAY' ]

console.log([].concat(...arr1));
// [ 'JAN', 'FEB', 'MAR', 'APR', 'MAY' ]

What ilenia says is right. And I suggest that if you get stuck, do what professional developers do - ask google. Seriously, looking things up is one of a developers most important skills.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.