← Back to challenges

The Fizz Buzz Test

JavaScriptHardlogicalgorithmsinterview

Instructions

Write a method that returns array of all the numbers from 1 to an integer argument. But for multiples of three use “Fizz” instead of the number and for the multiples of five use “Buzz”. For numbers which are multiples of both three and five use “FizzBuzz”.

Example

fizzBuzz(10) ➞ [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz"]

fizzBuzz(15) ➞ [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz"]

Notes

Make sure to return an array.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Lowercase and Uppercase Map