Skip to content

Instantly share code, notes, and snippets.

@PlenipotentSS
Created June 9, 2014 19:20
Show Gist options
  • Save PlenipotentSS/54071ff6310708102a02 to your computer and use it in GitHub Desktop.
Save PlenipotentSS/54071ff6310708102a02 to your computer and use it in GitHub Desktop.
NESTED LOOP
// NESTED FOR LOOP:
for(var i=0;i<3;i++) { //declare i=0; stop if i >=3; increase i by 1 after each run
for (var j=0;j<2;j++) { //declare j=0; stop if j>=2; increase j by 1 after each run
console.log(i+" "+j) //prints i and j for each iteration
}
}
//this should returns:
//
// 0 0
// 0 1
// 1 0
// 1 1
// 2 0
// 2 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment