Tell us what’s happening:
Solved it but why do we use the spread syntax? If we were to pass in the argument arr only into the newArr why don’t we get the same/wanted result? Thx!
Your code so far
function copyMachine(arr, num) {
let newArr = [];
while (num >= 1) {
// Only change code below this line
newArr.unshift([arr]);
// Only change code aove this line
num--;
}
return newArr;
}
console.log(copyMachine([true, false, true], 2));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60
Challenge: Basic Data Structures - Copy an Array with the Spread Operator
Link to the challenge: