Tell us what’s happening:
I don’t understand the use of “num–” in this code.
Your code so far
function copyMachine(arr, num) {
let newArr = ;
while (num >= 1) {
// Only change code below this line
newArr.push([…arr])
// Only change code above this line
num–;
}
return newArr;
function copyMachine(arr, num) {
let newArr = [];
while (num >= 1) {
// Only change code below this line
newArr.push([...arr])
// Only change code above this line
num--;
}
return newArr;
}
console.log(copyMachine([true, false, true], 2));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15
.
Challenge: Copy an Array with the Spread Operator
Link to the challenge: