GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — javascript-2/loops/dowhile.md at master · FarajDEV/javascript-2

Expand file tree

/

dowhile.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
33 lines (27 loc) · 723 Bytes
/

dowhile.md

Copy path

File metadata and controls

33 lines (27 loc) · 723 Bytes
Raw
Copy raw file
Download raw file
Edit and raw actions

Do...While Loop

The do...while statement creates a loop that executes a specified statement until the test condition evaluates to be false. The condition is evaluated after executing the statement. Syntax for do... while is

do {
  // statement
} while (expression);

Lets for example see how to print numbers less than 10 using do...while loop:

var i = 0;
do {
  document.write(i + " ");
  i++; // incrementing i by 1
} while (i < 10);

Note: i = i + 1 can be written i++.

{% exercise %} Using a do...while-loop, print numbers between less than 5. {% initial %} var i = 0; {% solution %} var i = 0; do { i++; // incrementing i by 1 } while (i < 5); {% endexercise %}

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.