Created
April 14, 2018 00:37
-
-
Save JeremyRH/378227d65a19e3cb7a916280050633d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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