Array with the Spread Operator

Tell us what’s happening:

Your code so far

function copyMachine(arr, num) {
  let newArr = [...arr]; 
  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));

Your browser information:

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

Link to the challenge:

It will make it easier for others to help if you:

  • explain what you are confused about (if you’re not sure about how to start),
  • explain what your thinking was in your initial attempt to solve the challenge,
  • ask specific questions.

What’s your question?

That doesn’t do anything about what the instructions say. Also, it’s outside of the place to edit :wink:

only thing you have to do is create a new array and copy the original array elements with spread operator , and then push the newly created array into the already created newArr inside while loop