vendredi 18 septembre 2015

Javascript - for loops & if-else statements - syntax error

//my code (with extra semi-colons)

for (var i=1; i < 11; i++) {
if (i<4) {
    console.log("Your number is between 1 & 3.");}
else if (i>7) {
    console.log("Your number is between 8 & 10.");}
else if {
    console.log("Your number is between 4 & 7.");}
}

I understand I do not need the semi-colon after the (), but I'm confused as to why not. Why exactly is the semi-colon not needed?

Any help would be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire