3....and the good


#1


Replace this line with your code.


#2

This isn't working for me and I'm not really sure what I'm missing

for(var i = 1; i <= 20; i++){
console.log(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);}


#3

agree with me that when the if condition evaluates to true, the rest of the conditions (else if and else) are not getting evaluated and the loop is moving on to the next number?

this means for 15 (which should print fizzbuzz) prints fizz because your if condition is true

checking if a number is fizzbuzz should be your if condition


#4

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