FizzBuzz
EasyLoops · JavaScript
The task
Write fizzBuzz(n) that returns an array of strings for the numbers 1 to n.
For multiples of 3 use "Fizz", for multiples of 5 use "Buzz", and for multiples of both use "FizzBuzz". Otherwise use the number as a string.
Examples
- fizzBuzz(5) returns ["1","2","Fizz","4","Buzz"]
Your code runs in your browser, in a separate worker, and is never sent to us. Edit the function, then press Run tests. Your work is saved here as you type.
JavaScriptCtrl or Cmd + Enter to run