Instantly share code, notes, and snippets.

Embed
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() );
}
@monsat

This comment has been minimized.

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