Skip to content

Instantly share code, notes, and snippets.

@gerasimua
Created May 22, 2014 15:47
Show Gist options
  • Save gerasimua/c67599318a675a40f13e to your computer and use it in GitHub Desktop.
Save gerasimua/c67599318a675a40f13e to your computer and use it in GitHub Desktop.
SmartGame
var f = function(c){
var g = function(){return Math.floor(Math.random()*3);}
var colors = ['red', 'green', 'blue'];
var r = g();
if(typeof c == 'undefined'){ c = 'red'}
while(colors.indexOf(c) === r){r = g();}
document.body.style.backgroundColor = c;
document.body.innerHTML = colors[r];
setTimeout(function(){f(colors[r])}, 1000);
}
document.body.style.height = "100%";
document.body.style.color = '#ffffff';
document.body.style.fontSize = '64px';
document.body.style.textAlign = 'center';
document.body.style.paddingTop = '15%';
document.body.style.backgroundImage = 'none';
f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment