Didn't log


I wrote:

for (var i = 105; i <= 1; i - 5) {

It says:

Oops, try again. Your loop didn't log 100 to the console!

I don't know what it means by this.


Will this not cause an infinity loop?

you do i - 5, but then each time your i will be 105 again, and never becomes zero. You need to do

var i = 105; i <= 1; i  = i - 5

also, if you take steps of 5, it will only take around 20 times before i is zero, not logging 100 times, but only logging 20 times


It won't cause an infinity loop, I checked it. Thanks for the help @stetim94 .


It still doesn't work.


I do console.log(i) inside the { } of the "for" loop, right?


Yes, you do. And i have a bit of problem with my console, give me a second. Do you have any output?


No, I don't have any output.


Long day, i should go to bed. Anyway, this loop will never execute, why?

Because of this:

var i = 105; i <= 1;

105 is bigger then 1, so the condition is true, so the loops end it should be the other way around:

var i = 105; i >= 1;

now the loop decreases until it is 0, then it stops because condition is met. now you do need i -=5 otherwise you will have a infinity loop.


Ohhhhh, thank you so much I never even noticed that!