javascript - While loop inside while loop [Javacript] -
how use while loop inside while loop without executing next loop (from outside while loop) unless 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 problem here @ end of inner loop, y
set 10
, never reset 0. try instead:
var x = 0; var y = 0; while(x < 10){ while(y < 10){ console.log(y); y++; } y = 0; x++; }
otherwise, once inner loop finishes once, never runs again.
Comments
Post a Comment