Why it's not working? All conditions are met


#1

I've got the code for this task. Why it's not working? All conditions are met..

 for(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);
        }
}

Need help on fizz buzz
#2

you have two quotes at the end, and with my code it wouldn't work unless fizzbuzz was the first one in the code


#3

Right answer is-

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

#4

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