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

Fizz Buzz Game Help

Okay,

Finally I've understood how to implement the fizzbuzz game using a "for" loop (cheated a little with google).

It is obvious to me now that my first attempt was on the wrong path (at least!) however, I still have this curiosity related to my first attempt:

Is it possible to taylor this code into a working fizz buzz game?

<code> var number = 1;

while (number <= 100) {

console.log(number);
number = number + 1;

var moduloThree = (number) % 3;
var moduloFive = (number) % 5;
var moduloFiveAndThree = (number) % 15;

if (moduloThree === 0) {

    console.log("Fizz");    

} 

if (moduloFive === 0) {

    console.log("Buzz");    

}

if (moduloFiveAndThree === 0) {

    console.log("Fizz Buzz");

} 

}

</code>

1 Answer

Anyone? :))