I need help. Introduction to Objects I - question 3. ...And the good!


#1

Does anybody understand why I'm getting this message -

'SyntaxError: missing before statement'

Here are the instructions:

Print out the numbers from 1 - 20. The rules:
For numbers divisible by 3, print out "Fizz"
.For numbers divisible by 5, print out "Buzz"
.For numbers divisible by both 3 and 5, print out "FizzBuzz" in the console.
Otherwise, just print out the number.

My code is below. Thanks in advance!

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

#2

Nevermind, I found out that I need to run the dual condition first and I've got it working now.


#3

if else(i % 3 === 0 && i % 5 === 0) {
    console.log("FizzBuzz")
    };
     ^

Take out the semi-colon there.


#4

in addition to what @lolman has said there is no such things as if else block


#5

ok, thanks for the help, guys.