Beginners JavaScript
  • Welcome!
  • Tutorial
    • Step 1: Hello World
    • Step 2: Data Types
    • Step 3: Comments
    • Step 4: Variables
    • Step 5: If/Else Statements
    • Step 6: For Loops
    • Step 7: Functions
    • Step 8: Arrays
    • Step 9: Objects
  • Challenges
    • Challenge 1: Age Difference
    • Challenge 2: Famous Writers
    • Challenge 3: Fix the Code
    • Challenge 4: FizzBuzz
    • Challenge 5: Needle in a Haystack
Powered by GitBook
On this page
  1. Challenges

Challenge 4: FizzBuzz

Write a for loop that prints the numbers from 1 to 100. But for multiples of 3 print “Fizz” instead of the number and for the multiples of 5 print “Buzz”. For numbers which are multiples of both 3 and 5 print “FizzBuzz”.

Counting to 15 should look like this:

1
2
'Fizz'
4
'Buzz'
'Fizz'
7
8
'Fizz'
'Buzz'
11
'Fizz'
13
14
'FizzBuzz'
PreviousChallenge 3: Fix the CodeNextChallenge 5: Needle in a Haystack

Last updated 6 years ago