Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Check please code of the task Fizz Buzz

Greetings guys,

Could you please check my code of this task? Thanks.

for (var count = 100; count; count=count-1) {
    if (count % 3) {
        console.log("fizz");
    }
    else if (count % 5) {
        console.log("buzz");
    }
    else if (count % 3 && count % 5) {
        console.log ("fizzbuzz");
    }
    else {
        console.log(count);
    }
};

2 Answers

hi, Dmitry, it's a bit hard to read when the code isn't properly formatted using Markdown code block.

But I'm pretty sure this code will never print "fizzbuzz"; count % 3 && count % 5 needs to be the 1st condition to check.

Thank you for adviсe. I will check the code again.