Last active
February 26, 2019 11:18
-
-
Save ishiduca/31b18996d9e2a3a10d9afbc5a26c095a to your computer and use it in GitHub Desktop.
This file contains 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 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)}"`) |
This file contains 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 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