Do While Loop

showing how to use a do while loop, i don't use these ones very often usually just a for loop.

function do_while_loop() {
  var ourArray = [];
  var i = 0;
  var max = 20;
  var out = "";
  do {
    out += i + ",";
  } while (i < max);

  var result_html = document.getElementById("result");
  result_html.innerHTML = out;


<div id='result' class='mb-3 alert alert-primary'>..</div>
<button onclick='do_while_loop();' class='btn btn-primary'>Run do_while_loop()</button>



Other Items in javascript
Page Views

This page has been viewed 332 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
All of humanity's problems stem from man's inability to sit quietly in a room alone, wrote Blaise Pascal.