Skip to content

Instantly share code, notes, and snippets.

@masawada
Created August 8, 2012 22:59
Show Gist options
  • Save masawada/3299574 to your computer and use it in GitHub Desktop.
Save masawada/3299574 to your computer and use it in GitHub Desktop.
Math.fizzbuzz
(function(){
if(!Math.fizzbuzz){
Math.fizzbuzz = function(n, i){
var i = i || 1;
var r = [];
while(i<=n){
var c = '';
if(i%3 === 0) c += 'Fizz';
if(i%5 === 0) c += 'Buzz';
if(c === '') c = String(i);
r.push(c);
i++;
}
return r;
};
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment