Skip to content

Instantly share code, notes, and snippets.

@JeremyRH
Created April 14, 2018 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyRH/378227d65a19e3cb7a916280050633d4 to your computer and use it in GitHub Desktop.
Save JeremyRH/378227d65a19e3cb7a916280050633d4 to your computer and use it in GitHub Desktop.
const divisibleBy = (divisor, int) => int % divisor === 0;
const fizzOrEmptyString = int => divisibleBy(3, int) ? "Fizz" : "";
const buzzOrEmptyString = int => divisibleBy(5, int) ? "Buzz" : "";
const fizzBuzz = int => fizzOrEmptyString(int) + buzzOrEmptyString(int) || String(int);
console.log(Array.from({ length: 100 }, (v, i) => fizzBuzz(i + 1)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment