3/33 Expected ';'


#1

Keep getting the above error message but can't seem to see where I'm going wrong.

for (var i = 1, i < 21, i++) {
    if (i % 3 === 0) {
        console.log("Fizz");
    };
    else if (i % 5 === 0) {
        console.log("Buzz");
    };
    else if (i % 3 === 0 && i % 5 === 0) {
        console.log("FizzBuzz");
    };
    else {
        console.log(i);
    };
};

#2

Get rid of the semicolons after conditions here is an explanation why they might be harmful:

Also reconsider the order of your conditions what cases are for example triggered when you enter the loop with i = 15. Currently the answer would be "Fizz" but it should be "FizzBuzz".


#3

Thanks for that! I've taken your advice and changed it (see below) but I'm still getting the same error message. Maybe I'm just missing something, but I really can't work it out.

for (var i = 1, i < 21, i++) {
    if (i % 3 === 0 && i % 5 === 0) {
        console.log("FizzBuzz")
    }
    else if (i % 5 === 0) {
        console.log("Buzz")
    }
    else if (i % 3 === 0) {
        console.log("Fizz")
    }
    else {
        console.log(i)
    }
};

#4

Oh yes, your using , instead of ; in your for loop just change that and it should work.


#5

That was it! Thanks for your help!