Created
February 20, 2012 15:15
-
-
Save usagi/1869620 to your computer and use it in GitHub Desktop.
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
| const number_of_begin = 1; | |
| const number_of_end = 20; | |
| const word_of_fizz = "Fizz"; | |
| const word_of_buzz = "Buzz"; | |
| function fizz(n){ return n % 3 == 0; } | |
| function buzz(n){ return n % 5 == 0; } | |
| for(var n=number_of_begin;n<=number_of_end;++n){ | |
| var is_fizz = fizz(n); | |
| var is_buzz = buzz(n); | |
| if(is_fizz) console.log(word_of_fizz); | |
| if(is_buzz) console.log(word_of_buzz); | |
| else if(!is_fizz) console.log(n); | |
| // for debug | |
| console.log("debug log:",n,is_fizz,fizz(n),is_buzz,buzz(n)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment