CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Destructuring with Rest

JavaScript code walkthrough · Question 34
hardArrays

Code

Read carefully. What does this print?
1let arr = [1, 2, 3, 4];
2let [first, second, ...rest] = arr;
3console.log(first + " " + second);
4console.log(rest.length);
5let combined = [...rest, first];
6console.log(combined.join(","));

Your answer