DEV Community

loading...

Discussion on: Unconditional Challenge: FizzBuzz without `if`

Collapse
indebanvdhamer profile image
Eric Nijman

This could probably get simplified (I've seen the one-liner of this one), but I still wanted to post mine

const fbMap = [
  () => 'FizzBuzz',
  String,
  String,
  () => 'Fizz',
  String,
  () => 'Buzz',
  () => 'Fizz',
  String,
  String,
  () => 'Fizz',
  () => 'Buzz',
  String,
  () => 'Fizz',
  String,
  String,
];
const fizzBuzz = x => fbMap[x % fbMap.length](x);
Forem Open with the Forem app