HELP! Oops, try again. You printed Fizz when you should have printed FizzBuzz


#1

There has to be something im missing. Please help me debug this code so i can move on. Thanks in advance. -Ryan

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

Your first evaluation needs to be the && comparison.

so it should read:
if(i%3===0 && i%5 === 0) { console.log("FizzBuzz");}

then the next two in the else if does not matter which order. But the && needs to be evaluated first, otherwise the system evaluates the first IF, finds the match, and stops progressing through the other "else" arguments.


#3

Spot on. Thank You! Happy Holidays!