How to use Do While loop in JavaScript

In this article I am going to explain about do while loop in JavaScript.
  • 2273

JavaScript do while loop

Do while loop is also a type of loop. In this this loop statement will be executed minimum one time because do while check condition at end of loop. its execute block of code until given condition is true.

Do while loop syntax


    //Your statement here

while (Variable> condition);

In this example it will display 1 to 10 natural number through do while loop



    <script type="text/javascript">

         function MyFunction() {

            do {

                document.write(i + ",");



            while (i < 11);





    <button onclick="MyFunction()">







Further Readings

You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.