Skip to content

Instantly share code, notes, and snippets.

@ecancino
Last active May 26, 2017 13:38
Show Gist options
  • Select an option

  • Save ecancino/7ea917792bf7aeef2bce to your computer and use it in GitHub Desktop.

Select an option

Save ecancino/7ea917792bf7aeef2bce to your computer and use it in GitHub Desktop.
Fizzbuzz
#!/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