Copy with Spread Operator Issue

Tell us what’s happening:
Describe your issue in detail here.

I’m not sure what’s going on here.
I used […arr] to copy the array and used .push() to add it to the new array.
I’m getting [ [ true, false, true ], [ true, false, true ] ] but can’t get the code to work for the other tests.

  **Your code so far**
function copyMachine(arr, num) {
let newArr = [];
while (num >= 1) {
  // Only change code below this line
newArr = [[...arr]];
newArr.push(arr) ;

  // Only change code above this line
  num--;
}
return newArr;
}

console.log(copyMachine([true, false, true], 2));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Copy an Array with the Spread Operator

Link to the challenge:

You are replacing the newArr on every single loop iteration.

Try using 3 instead of 2

Thank you. It didn’t click to me that the newArr was being replaced with every iteration. Problem solved. Much appreciated.