Skip to content

Instantly share code, notes, and snippets.

@monsat

monsat/FizzBuzz.js

Created Oct 10, 2011
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.

Copy link
Owner Author

@monsat monsat commented Oct 10, 2011

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

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