11. Review : Syntax Error



I usually don't prefer coming to the forum for help; rather solving it on my own, but i've been stuck on this one for awhile. The error is: SyntaxError: Unexpected token } I'm guessing it's a silly mistake, but it's better to ask. Thank you!

var cooking = ["flour ", "eggs ", "and", "sugar"];
for(var i = 0; i < cooking.length; i++) {
    console.log("Now add the " + cooking[i]);

 var eggs = false;
 while(eggs) {
     console.log("Keep going!");
    eggs = true;
    var i = true;
  do {
    } while(i);



yes, it is a silly mistake

remove the "}" or add one, i leave it to you

open and close it :slight_smile:


The last closing } is stray as there's no opening bracket thus the syntax error

BUT that isn't the only error in your code, if you run it your browser is going to crash as you have an infinite loop.

You haven't set any limit to the loops thus its going to keep on running till the browser freezes or crashes.


whoops that would create an infinity loop


ah thank you! I'll look through my old lessons :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.