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


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

Edit: Added the error.


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!");


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


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.


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