Skip to content

Instantly share code, notes, and snippets.

@akumpf
Created January 11, 2013 22:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akumpf/4514442 to your computer and use it in GitHub Desktop.
Save akumpf/4514442 to your computer and use it in GitHub Desktop.
(function(){
var i = 0;
var j = 0;
var k = 0;
var m = 0;
function forloop1(){
if(i<5){
j = 0;
forloop2();
}else{
console.log("all done");
}
}
function forloop2(){
if(j<5){
k = 0;
forloop3();
}else{
i++;
setTimeout(forloop1, 0);
}
}
function forloop3(){
if(k<5){
m = 0;
forloop4();
}else{
j++;
setTimeout(forloop2, 0);
}
}
function forloop4(){
if(m<5){
console.log(i,j,k,m);
m++;
setTimeout(forloop4, 0);
}else{
k++;
setTimeout(forloop3, 0);
}
}
forloop1();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment