DO/WHILE syntax error


#1


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


I'm getting this error message: "SyntaxError: missing before statement." When I change the code to "while(x);" and "x=false;" it works fine and prints my line once, so I don't understand why I get a syntax error here.


var getToDaChoppa = function(){
    do {
      console.log("This should print four times.")
      } while(x < 4);
};

var x = 0;
var x += 1;

getToDaChoppa();


#2

the placing of your var x = 0; and var x += 1; is not great. I would place them inside the function/loop. You figure it out. When updating a variable, not use the var keyword, using the var keyword will try to create a new variable instead of updating a old one


#3

Thanks, I get it now. I set var "x" on line 1 and placed "x += 1" by itself after "console" line and it works fine.