Created
April 26, 2015 23:09
-
-
Save Gwash3189/ddfc27245baad2e36cbd to your computer and use it in GitHub Desktop.
FizzBuzz Kata
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
var fizzBuzzKata = function() { | |
var limit = 100; | |
var mod = function(mod, value){ | |
return (mod && value) ? value % mod === 0 : value; | |
}; | |
var modFifteen = function(i){return mod(15, i);}; | |
var modFive = function(i){return mod(5, i);}; | |
var modThree = function(i){return mod(3, i);}; | |
var fizzBuzz = function(){console.log("Fizz Buzz");}; | |
var buzz = function(){console.log("Buzz");}; | |
var fizz = function(){console.log("Fizz");}; | |
var log = function(value){console.log(value);}; | |
for(var i = 1; i <= limit; i++){ | |
modFifteen(i) ? fizzBuzz() : | |
(modFive(i) ? buzz() : | |
(modThree(i) ? fizz() : | |
log(i); | |
) | |
); | |
} | |
}; | |
fizzBuzzKata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment