FizzBuzz by JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
コードの分かりやすさでいえば最初のやつかな?短く書くなら2つ目。