Created
February 17, 2014 19:06
-
-
Save sethetter/9056903 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
#!/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