Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active August 29, 2015 14:25
Show Gist options
  • Save unitycoder/7923ad5ba457caea3451 to your computer and use it in GitHub Desktop.
Save unitycoder/7923ad5ba457caea3451 to your computer and use it in GitHub Desktop.
2 For Loops in 1
// 2 loops in 1 : https://jsfiddle.net/rntasz32/2/
var width=3;
var height=3;
var size = width*height;
var x = 0;
var y = 0;
for (var i = 0; i < size; i++)
{
x = (i / 3) | 0;
y = i % 3;
document.getElementById('output').innerHTML += "x:"+x+" y:"+y+"\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment