Help on FizzBuzz


#1

I'm stuck with the code. I get the point that if you divide for example 15 by 3 it gives Fizz. so it won't run the code if 15 also can devidid by 5. So you dont get Fizzbuzz. But how do i get that code? I don't see/know where i went wrong.

Thanks for helping me.


https://www.codecademy.com/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661#

Oops, try again. It looks like you printed out the wrong number of items.

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


#2

Take the ; out of your for statement and enclose the if statements in { }.

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

#3

thanks for helping. I've finished this lesson now:slight_smile:


#4

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