Answers for "Copy an Array with the Spread Operator"

1

Copy an Array with the Spread Operator

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));
Posted by: Guest on April-21-2021

Code answers related to "Copy an Array with the Spread Operator"

Browse Popular Code Answers by Language