From: j8takagi Date: Tue, 30 Oct 2012 03:26:29 +0000 (+0900) Subject: JavaScript版を無名ファンクションを使った記述に変更 X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e6e0e248b8a85113bfc2681199bd941b7dd69d1;p=fizzbuzz.git JavaScript版を無名ファンクションを使った記述に変更 --- diff --git a/javascript/fizzbuzz.js b/javascript/fizzbuzz.js index d4971b0..3a6fbe4 100644 --- a/javascript/fizzbuzz.js +++ b/javascript/fizzbuzz.js @@ -1,10 +1,3 @@ -min = 1; -max = 100; - -for(i = min; i <= max; i++) { - fizzbuzz_puts(i); -} - function fizzbuzz_puts(n) { fizz = (n % 3 == 0); buzz = (n % 5 == 0); @@ -18,3 +11,12 @@ function fizzbuzz_puts(n) { document.write(n, "
\n"); } } + +(function () { + var min = 1; + var max = 100; + + for(i = min; i <= max; i++) { + fizzbuzz_puts(i); + } +})()