8. When to (call for help) while and when to (give up) for


#1


Hello guys, I am having a syntax error and I don't know what I am doing wrong

Edit: Added the error.

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


SyntaxError: Unexpected token for

var loopWhile = function (){
  while (Math.random() > 1) {
      console.log(" I am doing a while loop!");
  }
};
var loopFor = for (var i = 1; i > 10; i++) {
    console.log(" I am doing a for loop!");
}
loopWhile();
loopFor();


#2

Might want to give the syntax error to help people search for the problem


#3

I left comments above. You may also want to check your use of the > greater than sign in your for loop. If i=1, it will never be greater than 1 and won't run the loop.


#4

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