I don't understand my syntax error!


#1


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


Apparently there is a syntax error, but I can't find it.
Error messages:
"Oops, try again. There was a problem with your syntax."
"SyntaxError: Unexpected token {"
Please Help me find the syntax error. Thank you


var soloLoop = function(){
    // ^Declaring the loop function
  var c = true;
  //^Declares the condition variavle
  for (c) {
      //^^ Checks if the var c is true
      console.log("Looped once!");
      // ^^^ If the condition is true
      c = false;
      // ^^^^ Sets c to false so that it does not loop again
  }
  
};

soloLoop();
// ^^ Calls the loop function


#2

Hi,

The URL you posted is for a lesson on while loops you have created a for loop.

The syntax of a while loop looks like this:

while(condition) {
    // Do something!
}

Go though the lesson description and instructions again so that you can understand, If you still require help thereafter then paste in your code and we can help you.


#3

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