7/13 practice counting down what i'm i doing wrong need help


#1

for (var i = 10; i >= 1; i++) {
console.log(i);
}


#2

Well you are doing great but just one thing. if you are counting down then you need to keep decresing i after printing it instead of increasing it


#3

Well truthfully this for loop could almost never be wrong since the initialization and condition are the same, or am I wrong in that assumption?


#4

The loop is not wrong but it is infinite and will crash the program


#5

Right I was thinking of the other way around, where if the condition was less than i. I see now that understandably you are correct that it wouldn't work.


#6

this worked for me..........try it

(var i = 10; i > -1; i--) 
{
console.log(i);
}

as per instruction i will start counting from 10 downwards including 0 so to include 0 i hv used this "i>-1"...hope it help...


#7

for (var i = 10; i >= 0; i--) {
console.log(i);
}
It`s worked fine.
Needed to understand only 2 moments:

  1. To put 0 (because we count to 0 in our condition)
  2. After "i" to put "--". Because we are decrease our number.