From 036579b986d0f121860ef8f4a86b71cad2a2b980 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 12 Sep 2010 23:03:45 -0600 Subject: [PATCH] simpler fizzbuzz --- fizzbuzz.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/fizzbuzz.js b/fizzbuzz.js index 93c89da..ae9bfb9 100755 --- a/fizzbuzz.js +++ b/fizzbuzz.js @@ -2,20 +2,12 @@ "use strict"; var sys = require('sys'); (function () { - var i, n; + var i, msg; for (i = 1; i <= 100; i += 1) { - n = false; + msg = ''; - if (0 === (i % 3)) { - n = true; - sys.print("Fizz"); - } - if (0 === (i % 5)) { - n = true; - sys.print("Buzz"); - } - if (true === n) { - sys.print("\n"); - } + if (0 === (i % 3)) { msg += "Fizz"; } + if (0 === (i % 5)) { msg += "Buzz"; } + if (msg.length > 0) { console.log(msg); } } }());