8 last practice for loops SyntaxError: Unexpected Token


#1

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

Even when I remove the las semi colon I still get an error. What am I doing wrong?


#2
 1  for (var i = 100; i > 0; i-=5;) { 
 2  console.log(i); 
 3  };

hi.
In line 1: // you´re missing something in i > 0
this is the part where you´re supposed to say that you for loop starts in from " 0" , then ends in i = 100 in i -= 5 .
In line 1, there is also a syntax mistake in i -= 5 ;)


#3

@mara15 is right about the syntax error, just delete the semicolon after i-=5. You just need 2 semicolons to seperate the 3 parts of the for loop. But the rest seems to be ok you start at 100 and decrease in steps of 5 till you come to 0.


#4

for (var i = 100; i >= 1; i-=5) {
console.log(i);
}
/*do this*/


#5

This is perfect! Thx


#6

I always get this error.


#7

For me it was slightly different as I got an error when I submitted my code, so instead of 100, I changed it to 50 as shown below.

for (var i = 50; i > 0; i-=5) {
console.log(i);
}


#8

Okay, I got this to work. The problem

for (var i = 100; i > 0; i-=5;)
should have been

for (var i = 100; i > 0; i-=5)

No semi colon after the 5. I spent way to much time on this, thanks!