When to 'while' and when to 'for'


#1


I don't understand what I did wrong can someone show me, please. It's not crashing so I know it's not infinite.


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


Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token }

var chair = true
while(chair) {
    console.log("Ugh work already");
chair = false
    }
}
for (var i = 1; i < 1000; i+= 50) {
    console.log(i);
};


#2

Remove a closing curly brace between the while loop and the for loop.


#3

Wow that worked I would have never seen that thank you!


#4

Just check for extra parenthesis and curly braces ALWAYS, especially if it gives that error.


#5

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