Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js do while

/*
`do while` is essentially like the basic `while` statement
except for one key difference, the body is always executed
at least once.

Syntax:
do {
	body
} while (condition);

This is generally only useful if you need the body to run
at least once, before the condition is checked.
*/

let i = 10;
do {
	console.log(i);
	i--;
} while (i > 0);

/*
Outputs:
10
9
8
7
6
5
4
3
2
1
*/
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js
ADD COMMENT
Topic
Name
9+2 =