#9 most askedVery commonEasyArrays & objects
FizzBuzz
๐ข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.Write fizzBuzz(n) that returns an array of strings for the numbers 1 to n: multiples of 3 โ "Fizz", multiples of 5 โ "Buzz", multiples of both โ "FizzBuzz", otherwise the number as a string.
fizzBuzz(5) โ ["1", "2", "Fizz", "4", "Buzz"]
๐งช Practice
Write your solution, then press Run tests. Explain your approach out loud as you go.
function fizzBuzz(n) {
// your code here
}
Output appears here. Press Run or Ctrl/โ + Enter.
Try it first. Struggling for a few minutes is how it sticks.