WDI Fundamentals

WDI Fundamentals Unit 9


Your Turn

If you don't see the JS Bin below, please refresh the page. Here's the starter code for your next exercise:

JS Bin on jsbin.com

Last time, we wrote code that took an input, x, and set a new result value according to a specific set of rules. This time, your challenge is to loop through every number from 1 to max, applying those exact same rules to each number and, finally, printing the result out in the console using the command console.log(result);.

For reference, if max is 20, the following should be displayed in the console:

1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
16
17
fizz
19
buzz

Testing any number less than 20 should give you a subset of that result — in other words, if max is 5, we get the following:

1
2
fizz
4
buzz

Stuck? Check out the solutions to see what you can do.


Feeling confident? Test your understanding of this lesson with this quiz.