Welcome to the 25th Easy JavaScript tutorial, part of EasyProgramming.net. In this tutorial, we cover the 'do while' loop.
If you haven't already, I would highly recommend that you watch my "do while" loop tutorial in C++.
It's a very old tutorial, but it's still relevant because the syntax of a do-while loop in C++ is the exact same as JavaScript.
The do while loop allows you to run a block of code as long as a specific condition is true. Unlike the while loop, the do while loop will ALWAYS run at least once before it checks the condition.
do while
loop:do{ code to be executed - this code is run at least once } while (condition is true);
To fork the fiddle and follow along: https://jsfiddle.net/easyjs/rpwooysh/
Remember to checkout the Resources section below for associated downloadable content, JSFiddle links, and other resources. Watch the video and follow along!