Why isnt it printing "FizzBuzz" for 15


#1

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

because you have inverted your if statement
when a conditon is true the program doesn't read others else if and else

try

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

#3

for(i=1;i<21;i++){

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

}