Lesson 8


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-NhsaT/1/3?curriculum_id=506324b3a7dffd00020bf661#


The error is telling me that I am missing a ')' but I can't seem to find it. SyntaxError: missing ) after for-loop control


// Write your very own for loop!
for (var i = 100; i >= 0; i=- 5;) {
    console.log(i)
}


#2

@feephill,
You have one semi-colon-; too many....
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for


#3

The semicolon after i =- 5 shouldn't be there, and console.log(i) should have a semicolon after it like this, console.log(i);
Hope this helped :slight_smile: a lot of people make these small mistakes and it can take quite a while to find them sometimes.


#4

you should take out the equal for the lesson


#6

I do not understand what is the reason, what is wrong?


#7

Your loop starts by creating variable i with initial value 100. And you stated that your loop should iterate as long as i <= 0.

But 100 is not <= 0, so body of the loop will not be executed at all.

You probably wanted to use i >= 0 condition.


#8

@webhero

for ([initialization]; [condition]; [final-expression]) {
   statement
}

In your FOR loop condition use i >= 0


#9

Thanks! This code was right:

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


#10

You're very welcome :slight_smile:


#11

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

Above is my code but I keep getting this error.
Oops, try again. There was a problem with your syntax.
What am I doing wrong?


#12

Nevermind...I was using int instead of var. Fixed.