Copy machine code not working

Copy machine code not working


newArr.push([…arr]); didn’t work i’m confused

Copy an Array with the Spread Operator...arr

What is your full code?


herer is my code:

function copyMachine(arr, num) {
  let newArr;
  while (num >= 1) {
    // change code below this line
    // change code above this line
  return newArr;

// change code here to test different cases:
console.log(copyMachine([true, false, true], 2));


That is because you declared newArr but never assigned it a value. Inside your while loop you start trying to call the push method on newArr, but newArr was never declared as an array.


thanks it works perfectly