3. need debug


#1


Please help me debug this code, thank you.


for (var i = 1 ; i <= 20 ; 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

if a number is divisible by 3 and 5, it also divisible by 3 or 5, so for example 15:

if (15 % 3 === 0)

is true, so fizz will be printed.once if is executed, else if/else won't be executed)

to check if a number is fizzbuzz should be the first condition


#3

Thank you, #Stetim94, you are the best!


#4