Essential JavaScript

FizzBuzz Kata

FizzBuzz is an old kata. You can Google it. It has history. It also has it's own Wikipedia article.

This particular kata actually started out as a children's game to learn division. It evolved into a coding challenge used in job interviews to screen programmers.

The challenge goes like this:

Write a program that prints the numbers from 1 to 100, but for multiples of three print "Fizz" instead of the number and for multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

You will need to write a function that accepts a number (from 1 to 100).

  • By default, return that number as the result.
  • However, if the number is divisible by 3, return "Fizz" instead.
  • If the number is divisible by 5, return "Buzz" instead.
  • For numbers divisible by both 3 and 5, return "FizzBuzz".

Code Editor