Skip to content

Instantly share code, notes, and snippets.

@sethetter
Created February 17, 2014 19:06
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 sethetter/9056903 to your computer and use it in GitHub Desktop.
Save sethetter/9056903 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
// http://upfrontwichita.com/challenges/3
/**
* fizzBuzz
*/
var fizzBuzz = function(low, high) {
var result = [];
if (typeof high === 'undefined') high = low;
for (var i = low; i <= high; i++) result.push(checkNum(i));
return result;
};
var checkNum = function(num) {
if (num % 3 === 0 && num % 5 === 0) return 'fizzbuzz';
if (num % 3 === 0) return 'fizz';
if (num % 5 === 0) return 'buzz';
return num;
};
module.exports = fizzBuzz;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment