Skip to content

Instantly share code, notes, and snippets.

@kokdemo
Created August 19, 2014 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokdemo/77038d845ae0961ccb11 to your computer and use it in GitHub Desktop.
Save kokdemo/77038d845ae0961ccb11 to your computer and use it in GitHub Desktop.
function cheat() {
var color1, color1box, color2, color2box;
var boxes = document.querySelectorAll('#box > span'),
boxLen = boxes.length;
for (var i = 0; i < boxLen; i++) {
var box = boxes[i],
color = box.style.backgroundColor;
if (i == 0) {
color1 = color;
color1box = box;
} else if (!color2) {
if (color != color1) {
if (i > 1) {
box.style.background = 'black';
setTimeout(cheat);
return;
} else {
color2 = color;
color2box = box;
}
}
} else {
setTimeout(cheat);
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment