Copy an Array with the Spread Operator3

Copy an Array with the Spread Operator3
0.0 0

#1

Tell us what’s happening:

I don’t get what method to use. Push?

Your code so far


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

newArr.push([…arr]);

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

// change code here to test different cases:
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/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator


#2

Make sure you are using three dots before arr. It appears you have something different above.


#3

method push is correct