Skip to content
WANCODE
BM

FizzBuzz on the Page

15 minBeginnerJavaScript

FizzBuzz is the classic warm-up that checks you can combine a loop, conditions and the remainder operator %. Here you'll also put the result on the page.

  • Multiples of 3 → "Fizz"
  • Multiples of 5 → "Buzz"
  • Multiples of both 3 and 5 → "FizzBuzz"
  • Anything else → the number as a string, e.g. "7"
JavaScript
fizzbuzz(5)   // ["1", "2", "Fizz", "4", "Buzz"]
fizzbuzz(1)   // ["1"]
fizzbuzz(0)   // []

Examples

Then display fizzbuzz(15) on the page: one <li> per item inside <ol id="output">, in order.

Implement fizzbuzz(n) so it returns the FizzBuzz sequence from 1 to n as an array of strings, then show fizzbuzz(15) on the page as 15 <li> items inside #output.

Checks

  • fizzbuzz(15) is correct
  • Works for 0, 1 and larger n
  • The page shows 15 items
Preview

Console output from your code appears here.

Step 1 of 1