Why will my for and while loops never work!?


#1

This just DOES NOT work...I ALWAYS get the 'expected ';'' error EVERY time I try and write a for and while loop, no idea which one is actually running incorrectly! Help me identify the bug plz


// Write your loop below!
var myNumber = 5;
for (myNumber = 1; myNumber < 10, myNumber = myNumber + 1) {
console.log(myNumber);
}
var understand = true;
while (understand) {
    console.log("Hello!");
    understand = false;
}


#2

This error says everything

expected ;

for (myNumber = 1; myNumber < 10, myNumber = myNumber + 1)

myNumber < 10, <<< here a semicolon

AND

myNumber = myNumber + 1

this is more common

myNumber++

#3

Oh yes! Thanks so much :smiley: I knew it would be a simple mistake, but hard to spot...I appreciate your help :smile:


#4

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