Reputation: 987
How would I turn these for statements into a while statement in javascript:
for (left = gridPlace; left <= gridLastPlace; left++){
for (right = gridOtherPlace; right <= gridLastOtherPlace; right++)
}
Thanks
Upvotes: 0
Views: 97
Reputation: 700412
A for (x; y; z) { ... }
is the same as x; while (y) { ... z; }
, so your loops would be:
left = gridPlace;
while (left <= gridLastPlace) {
right = gridOtherPlace;
while (right <= gridLastOtherPlace) {
...
right++;
}
left++;
}
Upvotes: 4
Reputation: 16718
var left = gridPlace;
while(left <= gridLastPlace)
{
var right = gridOtherPlace;
while(right <= gridLastOtherPlace)
{
right++;
}
left++;
}
Upvotes: 1