Skip to content

Instantly share code, notes, and snippets.

@ishiduca
Last active February 26, 2019 11:18
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 ishiduca/31b18996d9e2a3a10d9afbc5a26c095a to your computer and use it in GitHub Desktop.
Save ishiduca/31b18996d9e2a3a10d9afbc5a26c095a to your computer and use it in GitHub Desktop.
const fizz = n => n % 3 === 0 ? 'Fizz' : '';
const buzz = n => n % 5 === 0 ? 'Buzz' : '';
const test = n => ([fizz, buzz].map(f => f(n)).filter(Boolean).join(' ') || n;
for (let i = 0; i < 31; i++) console.log(`"${test(i+1)}"`)
// const p = str => o => n => n % o ? null : str
// const test = n => [p('Fizz')(3), p('Buzz')(5)].map(f => f(n)).filter(Boolean).join(' ') || n
const p = (str, o) => n => n % o ? null : str
const test = n => [p('Fizz', 3), p('Buzz', 5)].map(f => f(n)).filter(Boolan).join(' ') || n
for (var i = 0; i < 100; i += 1) console.log(`"${test(i + 1)}"`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment