FizzBuzz問題
new function(){ var Make = function(name, round){ this.counter=0; this.name=name; this.round=round; }; Make.prototype.call=function(){ if(this.round==++this.counter){ this.counter = 0; OUTPUT += this.name; return true; } return false; }; var Fizz = new Make("Fizz",3); var Buzz = new Make("Buzz",5); var counter = 0; var Counter = function(max){ if(max!=counter++){ if(!(Fizz.call()|Buzz.call())){ OUTPUT += counter; } OUTPUT += ", "; return true; } return false; }; while(Counter(100)); OUTPUT += "end"; };
実行