Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Introduction to Programming Control Structures Loops

Extra credit (fizz buzz)

That is what I tried to do, hope it will be nice. Thank you, Marion

for (var counter = 100; counter > 0; counter--) {
  if (counter %5 == 0 && counter %3 == 0) {
    console.log('fizzbuzz');
  } else if (counter %5 == 0) {
    console.log('buzz');
  } else if (counter %3 == 0 ) {
    console.log('fizz');
  } else {
    console.log(counter)
  }
}

3 Answers

Erik McClintock
Erik McClintock
45,782 Points

Looks good, Marion! You can open up the console (in the developer tools of your browser) and paste your code in to see it in action, then you can verify yourself whether or not things are running as you'd expect :)

Keep it up!

Erik

Thanks Erik for your help !

Marion

Michael Bianchi
Michael Bianchi
2,488 Points

<html> <head> <script> for (var i = 1; i < 101; i++){

        if((i % 3 == 0)){
            console.log("fizz")} 
            else if(i % 5 == 0){
                    console.log("buzz");} 
                else {
                console.log(i);}
    }
    </script>
</head>

</html>