I hope everyone is doing well
I am going to share my understanding of how do-while loop work and i need YOU guys to tell am i,right or not?
Here is the code first:
let k= 1
do{
if(k===9){
k++;
continue;
}
console.log(k+1);
k= k+1;
}while(k<15);
So what this code does is it takes k=1 and in console.log(k+1) , it prints k = 2. And then 1 is added to K original value of 1 and it checks whether the condition is true or not.
If its true, then it will move forward to make another loop and check it.
And when k value reaches to 9, the IF condition becomes true and k++ adds 1 to 9 which is equal to 10 and before printing 10, continue statement terminate that loop and start another loop.
This is what i understood on how it works.
Thanks