Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
FizzBuzz by JavaScript
Number.prototype.fizzBuzz = function() {
return (this % 3 === 0 ? "Fizz" : "") + (this % 5 === 0 ? "Buzz" : "") || this.toString();
}
// main
for (var i=1; i<=100; i++) {
console.log( i.fizzBuzz() );
}
Owner

monsat commented Oct 10, 2011

コードの分かりやすさでいえば最初のやつかな?短く書くなら2つ目。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment