In JavaScript when to use while loop and when do-while loop ? | SoloLearn: Learn to code for FREE!

+1

In JavaScript when to use while loop and when do-while loop ?

6/5/2017 2:04:32 PM

GARG

4 Answers

New Answer

+18

Use the do while if you want the code to at least execute once....

+4

do { /* some actions to perform */ } while (/* some condition(s) tested after each iteration to do again or break loop */) while (/* some condition(s) tested before each iteration to do loop stuff or break it */) { /* some actions to perform */ }

+3

https://stackoverflow.com/questions/3347001/do-while-vs-while Maybe this stackoverflow thread could help you?

+1

I have understood the difference between them but I am not getting where to use which loop ?