8.last practice for loop


#1

for ( i=100; i<0; i-=5 ){
console.log(i)
}

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

what is wrong with my code,please, help me


#2

a for loop runs as long as the condition is true.
first run of the loop:
i = 100
i < 0
aka: 100 < 0, zero is not greater then 100. You might want to use > instead, this way the loop will run until the value is zero, then the condition is fasle


#3

but what if you changed it like that and it still doesnt work?


#4

then you should make your own topic with code + error message because then something else is wrong.This solution was specific for alexis


#5

2 posts were split to a new topic: 8. last practice for loop


#6

Oh its ok know
for (var i = 100; i >= 1; i-=5) {
console.log(i);
}

Thats the code if you want to know it but really thanks :wink:

BR


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.