Count from 1 to n and return every step as text in a list. For multiples of 3, use Fizz instead of the number. For multiples of 5, use Buzz. For multiples of both 3 and 5, use FizzBuzz.
fizzBuzz(5) returns ["1", "2", "Fizz", "4", "Buzz"].
n is between 1 and 100.
Input: fizzBuzz(5)
Output: ["1", "2", "Fizz", "4", "Buzz"]
Input: fizzBuzz(15)
Output: ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"]
Your solution is checked against 2 example tests and 4 hidden tests (edge cases and bigger inputs).
Languages you don't learn in class are worth more: C++ 1.25×, JavaScript, TypeScript, C, Rust and Go 1.5×. Your first solve in a language unlocks its "Learned" achievement: +25 for learning it.
Loading editor...
Run Code checks the example tests. Submit runs every test, including hidden ones.