simpler fizzbuzz

This commit is contained in:
AJ ONeal 2010-09-12 23:03:45 -06:00
parent 1b0eaf292e
commit 036579b986
1 changed files with 5 additions and 13 deletions

View File

@ -2,20 +2,12 @@
"use strict"; "use strict";
var sys = require('sys'); var sys = require('sys');
(function () { (function () {
var i, n; var i, msg;
for (i = 1; i <= 100; i += 1) { for (i = 1; i <= 100; i += 1) {
n = false; msg = '';
if (0 === (i % 3)) { if (0 === (i % 3)) { msg += "Fizz"; }
n = true; if (0 === (i % 5)) { msg += "Buzz"; }
sys.print("Fizz"); if (msg.length > 0) { console.log(msg); }
}
if (0 === (i % 5)) {
n = true;
sys.print("Buzz");
}
if (true === n) {
sys.print("\n");
}
} }
}()); }());