Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fizbuzz on crack
var fb = {
fbArr:['','','Fizz','','Buzz','Fizz','','','Fizz','Buzz','','Fizz','','','FizzBuzz'],
next:function(){
var index = this.count();
var total = this.total();
console.log(total + ':' + this.fbArr[index])
},
count:function(){
if(typeof(arguments.callee.index) == 'undefined')arguments.callee.index =-1;
arguments.callee.index ++;
if(arguments.callee.index>=15){
arguments.callee.index = 0;
}
return arguments.callee.index
},
total:function(){
if(!arguments.callee.total)arguments.callee.total =0;
arguments.callee.total ++;
return arguments.callee.total
}
}
fb.next();
fb.next();
for(var i=0; i < 100; i ++){
fb.next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment