11.Reveiw syntax error



I keep getting this error message: SyntaxError: Unexpected token

// Write your code below!

var x =1;
for (var i = 1; i < 11; i++) {
    // Prints numbers 1 - 10

var y = true
while(y==true) {
    // Avoid infinite loops!
    y = false;

do {
    console.log("I'm printed once!");
} while(x=2; X++);

I can't figure out what i'm doing wrong here someone help please.


This post was flagged by the community and is temporarily hidden.


Thanks it worked i never would have found that :slight_smile:


In the condition of your DO-WHILE you should put an expression which result's in a Boolean true or false
not as you are doing

(x=2; X++)

The Instructions:
To finish up and prove your loop mastery,
write three syntactically correct loops in the editor:
one for,
one while, and one do. Beware of infinite loops!

the for-loop:

the while-loop:

the do-while-loop: