Last active
May 26, 2017 13:38
-
-
Save ecancino/7ea917792bf7aeef2bce to your computer and use it in GitHub Desktop.
Fizzbuzz
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
| #!/usr/bin/env node | |
| 'use strict'; | |
| let _ = require('lodash'); | |
| const cicles = process.argv[2] || 100, | |
| fizzbuzz = (n) => { | |
| let word = '', | |
| divideBy = _.curry((b, d) => (d !== 0) && (d % b === 0)), | |
| divideBy3 = divideBy(3), | |
| divideBy5 = divideBy(5); | |
| word += divideBy3(n) ? 'fizz' : ''; | |
| word += divideBy5(n) ? 'buzz' : ''; | |
| return (word || n); | |
| }, | |
| fizzbuzz_to = _.partialRight(_.times, fizzbuzz); | |
| console.log( | |
| fizzbuzz_to(cicles) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment