Looking for the proper way to do this. I managed to get the answer, but I don't think it was how I was supposed to do it.
I'm supposed to use a for loop, to decremment var countDown by one each time the loops runs until it equals 0.
var countDown = 10;
for (let i=0; i < 5; i++)
countDown = countDown-i
console.log(countDown) // output 0;
I understand why my way works. But it doesn't decrement by one. Another way I thought was:
var countDown = 10;
for(i=0; i < 11; i++){
console.log(countDown-i);
}
console.log(countDown) // output 10, 9 , 8, 7, 6, 5, 4, 3, 2, 1, 0, 10
How would I globally change the countDown variable to 0?