5/11 SyntaxError: Unexpected token


#1

I keep getting "SyntaxError: Unexpected token" for the following code.

//Remember to set your condition outside the loop!
var count = 0;

var loop = function(){
while(count < 3;){
console.log "I'm looping!";
count++;
//Your code goes here!
}

};
loop();

Can anyone see what I am missing?


#2

Hey @bytesolver39907! Just a uneccesary semicolon after your while loop here:


Just put it as this:

while(count < 3){

And you should be fine! If your not please reply saying so


#3

Thanks. Removing the semicolon and adding parenthesis around the string did the trick. Works great now.


#4

that didn't work for me


#5

@stevah The reason it didn't work is because you have a semicolon after your console.log. A semicolon pretty much deactivates or makes the rest of the code on that line inactive. Try removing the semicolon. Like this:

console.log ("I'm looping!")

TRY THIS

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

};
loop();


#6

Actually the problem is that @bytesolver39907 forgot the () around the string he/she wanted to console.log.