Skip to main content

JavaScript: Do...While loop

Similar to while do while no matter what, it runs the loop without the satisfaction of the condition first and checks for the state at the end whether it needs to satisfy or not.





let age = 1

    console.log("Age of " +age+ " is allowed!")
while(age < 5)


Age of 1 is allowed!
Age of 2 is allowed!
Age of 3 is allowed!
Age of 4 is allowed!

Same as while loop here, it checks and does the execution of the do body first no matter it is false or true. Then it checks the condition at the end in while state and supposedly decides whether to satisfy or not.

Submitted by arilio666 on October 6, 2021

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.