All files / leetCode 0412.ts

100% Statements 11/11
100% Branches 6/6
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  3x   3x 23x 22x   16x   3x   13x     3x    
export default function fizzBuzz(n: number): string[] {
  const res: string[] = []
 
  for (let i = 1; i <= n; i++) {
    if (i % 15 === 0)
      res.push('FizzBuzz')
    else if (i % 3 === 0)
      res.push('Fizz')
    else if (i % 5 === 0)
      res.push('Buzz')
    else
      res.push(i.toString())
  }
 
  return res
}