What num-- does?

Tell us what’s happening:
hi, i’m new here and i need some help from you guys.

i’m learning data structure in javascript, so can any one tell me what the line num-- (right below newArr.push([…arr]) line) down in my code does?

thanks

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;
}

console.log(copyMachine([true, false, true], 2));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0.

Challenge: Copy an Array with the Spread Operator

Link to the challenge:

-- is a decrementor.
It’s introduced here:

2 Likes