Skip to content

Instantly share code, notes, and snippets.

@gabssnake
Created December 21, 2017 07:47
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 gabssnake/a158356462a7850f880edaa5c1b25154 to your computer and use it in GitHub Desktop.
Save gabssnake/a158356462a7850f880edaa5c1b25154 to your computer and use it in GitHub Desktop.
FizzBuzz
// Separate rules from work
const rules = { '3': 'Fizz', '5': 'Buzz' }
const fbuzz = i => Object.keys(rules).reduce((s, n) => s + (i % n ? '' : rules[n]), '') || i
for (let i = 1; i <= 100; i++) console.log(fbuzz(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment