Skip to content

Instantly share code, notes, and snippets.

@swindsor
Created January 11, 2012 20:20
Show Gist options
  • Save swindsor/1596575 to your computer and use it in GitHub Desktop.
Save swindsor/1596575 to your computer and use it in GitHub Desktop.
FizzBuzz
function cat(a,b,c){
return c ? (a + b) : (a);
}
function fizz(i,s){
return cat(s,"Fizz", (i%5===0));
}
function buzz(i,s){
return cat(s,"Buzz", (i%3===0));
}
function number(i,s){
return cat(s, i.toString(),((i%3!==0) && (i%5!==0)));
}
for(var i=1; i <= 20; i++){
console.log(number(i, buzz(i, fizz(i, ""))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment