SyntaxError: Unexpected token


I don't know why this code isn't working can someone please help.

var count = 0;

var loop = function();
while (count < 3 )
console.log( "I'm looping!;");
var count = false;




Let's see...

You put a ";" after

var loop = function( );

Remember the syntax:

var something = function () { 
while ( something ) { do something }


The second thing is you forgot to count++

You set the variable to 0. Inside the while you should count++. It will start counting from zero till <3.
You don't need to set count to false. It will stop when it count to 2.

And that loop function in the end should be empty. You're just calling it. No need to pass any values.

Your code should look like this:

var count = 0;

var loop = function(){
while(count < 3){
console.log("I'm looping!");


Try it. :wink:


It worked :smile: thanks I think the count++ really messed me up. thanks so much :smile: