DEV Community

Discussion on: FizzBuzz JavaScript

akhilpokle profile image
Akhil • Edited on

Nope, it would be the same since here I have modified the question for 4 conditions, ie 3,5,7,11. If we follow the original question ie checking for 3 & 5, then code will be :

let str = "";
for( i = 1;i<=n ; i++){
    if(n%3 == 0) str += "fizz";
    if(n%5 == 0) str += "buzz";
    else str += n;
return str;
Thread Thread
jpantunes profile image
JP Antunes • Edited on

Interesting. What do you think happens after each if statement?
Or in another way, what is the difference between two or more if's and a chain of if, else if, else?

edit: a picture of my cat doing a code review :-)

Thread Thread
akhilpokle profile image

oh yeah, that else part is a really bad bug from my side
it should be

if(str ="") str += n;

what this video :