Another FizzBuzz version

July 21, 2019

This is my version of the infamous FizzBuzz interview test.

const range = new Array(100).fill(0);
const f = 'Fizz';
const b = 'Buzz';

function isMod(mod) {
  return number => number % mod === 0;
}

const fizzBuzz = range.map((value, i) => {
  const count = i + 1;

  if (isMod(15)(count)) return f + b;

  if (isMod(3)(count)) return f;

  if (isMod(5)(count)) return b;

  return count;
});

Edit on codesandbox

What do you think? Tweet me!


Daniel Beutner

Personal blog by Daniel Beutner. Dad, coder and musician.