Last active
August 29, 2015 14:01
-
-
Save Nkzn/7a65da8e160e116a09df to your computer and use it in GitHub Desktop.
わかめ本読みながらなんとなく書いてみたFizzBuzz
This file contains hidden or 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
| /** | |
| * "003: Fizz" | |
| * "004: 4" | |
| * "005: Fizz" | |
| * のように、"count: word"の形式で、渡された数字と処理済みの文字を整形して表示する | |
| */ | |
| var logCount = (count: number, word = String(count)) => console.log(("00" + count).slice(-3) + ": " + word); | |
| for (var i = 1; i <= 100; i++) { | |
| if (i % 15 === 0) { | |
| logCount(i, "FizzBuzz"); | |
| } else if (i % 3 === 0) { | |
| logCount(i, "Fizz"); | |
| } else if (i % 5 === 0) { | |
| logCount(i, "Buzz"); | |
| } else { | |
| logCount(i); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment