11.Reveiw syntax error


#1

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

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
    console.log(i);
}

var y = true
while(y==true) {
    console.log("Hello!");
    // 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.


#2

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


#3

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


#4

@chipjumper02803
In the condition of your DO-WHILE you should put an expression which result's in a Boolean true or false
and
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:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for

the while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

the do-while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while