Skip to content

Instantly share code, notes, and snippets.

@sedera-tax
Created June 28, 2018 13:23
Show Gist options
  • Select an option

  • Save sedera-tax/38af8c563bf40126f840840c99f60de7 to your computer and use it in GitHub Desktop.

Select an option

Save sedera-tax/38af8c563bf40126f840840c99f60de7 to your computer and use it in GitHub Desktop.
Spread operator ES6
function copyMachine(arr, num) {
let newArr = [];
while (num >= 1) {
newArr.push([...arr]);
num--;
}
return newArr;
}
// change code here to test different cases:
console.log(copyMachine([true, false, true], 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment