Problem 19
FizzBuzz Recursion Challenge
Given a positive integer n, return an array of string values from 1 through n. For multiples of 3, use 'Fizz' instead of the number. For multiples of 5, use 'Buzz'. For numbers divisible by both 3 and 5, use 'FizzBuzz'. All other numbers should be their string representation.
Function Signature
fizzBuzz(n)
Parameters
n— a positive integer.
Output
Return an array of strings of length n.
Constraints
- The function must use recursion.
- Every element in the returned array must be a string.
- The function should accept exactly one argument.
Examples
fizzBuzz(5) → ['1', '2', 'Fizz', '4', 'Buzz']
fizzBuzz(15) → ['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', '7', '8', 'Fizz', 'Buzz', '11', 'Fizz', '13', '14', 'FizzBuzz']