#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.