I've been trying to figure out the proper way to achieve this task. Although I did find a solution, I'm not entirely sure if it's the correct approach.
The requirement is to utilize a for loop to decrement the variable countDown by one each time the loop runs until it reaches 0.
var countDown = 10;
for (let i=0; i < 5; i++)
countDown = countDown-i
console.log(countDown) // outputs 0;
While my method does work, it doesn't precisely decrement by one. Another alternative approach that crossed my mind was:
var countDown = 10;
for(i=0; i < 11; i++){
console.log(countDown-i);
}
console.log(countDown) // outputs 10, 9 , 8, 7, 6, 5, 4, 3, 2, 1, 0, 10
I'm now contemplating how I could globally change the countDown variable to 0?