Skip to content

Instantly share code, notes, and snippets.

@cpebble
Forked from chregon/fzbz.js
Last active September 17, 2020 13:31
Show Gist options
  • Save cpebble/4f34d9f2f8caeefbffe82e77f26cf44b to your computer and use it in GitHub Desktop.
Save cpebble/4f34d9f2f8caeefbffe82e77f26cf44b to your computer and use it in GitHub Desktop.
Fizzbuzz but can i do FP? no u
function iota (n) { // Pretty genius implementation
return [...Array(n).keys()]
}
function fizzbuzz (n) {
return iota(30).map( x =>
(x % 15 === 0 ? "fizzbuzz" : x % 3 == 0 ? "fizz" : x % 5 == 0 ? "buzz" : x.toString())
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment