How do I use while loop inside while loop without executing the next loop (from outside while loop) unless the inner while loop done executing?
var x = 0;
var y = 0;
while(x < 10){
while(y < 10){
console.log(y);
y++;
}
x++;
}
I'm guessing your problem here is that at the end of the inner loop, y is set to 10 and it never is reset to 0. Try this instead:
var x = 0;
var y = 0;
while(x < 10){
while(y < 10){
console.log(y);
y++;
}
y = 0;
x++;
}
Otherwise, once the inner loop finishes once, it never runs again.
y=0 after loop, move declaration of y inside loop as var y = 0.Put y initialization inside first while loop.
var x = 0;
while(x < 10){
var y = 0;
while(y < 10){
console.log(y);
y++;
}
x++;
}
y=0;before x++ycounter value?break;orcontinue;