And the good.. or not that good


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

What is wrong here?


what happens when you run it


says try again! You printed Fizz when you should have printed FizzBuzz.



okay..... try putting your last "else-if"condition as the first. remember to change it to an 'if' condition.


this worked for me
for (i=1;i<=20;i++){
if (((i%3)===0)&&((i%5)===0)){
else if ((i%3)===0){
} else if ((i%5)===0){
else {


Why does the FizzBuzz conditional need to come before all the others for it to work correctly?


Theres is more than one way to solve it. That is just the easiest way to do it.
Another way is by nesting the if statement, but you have to do it right. Or else the code will break.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.