Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf6d822

Browse filesBrowse files
committed
Merge pull request GitbookIO#76 from sumn2u/master
an example to show do while loop
2 parents e59994d + bd7da90 commit cf6d822
Copy full SHA for cf6d822

File tree

Expand file treeCollapse file tree

2 files changed

+36
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+36
-0
lines changed
Open diff view settings
Collapse file

‎en/SUMMARY.md‎

Copy file name to clipboardExpand all lines: en/SUMMARY.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* [Loops](loops/README.md)
2525
* [For](loops/for.md)
2626
* [While](loops/while.md)
27+
* [Do...While](loops/dowhile.md)
2728
* [Functions](functions/README.md)
2829
* [Declare](functions/declare.md)
2930
* [Higher order](functions/higher_order.md)
Collapse file

‎en/loops/dowhile.md‎

Copy file name to clipboard
+35Lines changed: 35 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Do...While Loop
2+
3+
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.
4+
Syntax for do... while is
5+
6+
```javascript
7+
do{
8+
// statement
9+
}
10+
while(expression) ;
11+
```
12+
13+
Lets for example see how to print numbers less than 10 using `do...while` loop:
14+
15+
```
16+
var i = 0;
17+
do {
18+
document.write(i + " ");
19+
i++; // incrementing i by 1
20+
} while (i < 10);
21+
```
22+
23+
>***Note***: `i = i + 1` can be written `i++`.
24+
25+
26+
{% exercise %}
27+
Using a do...while-loop, print numbers between less than 5.
28+
{% initial %}
29+
var i = 0;
30+
{% solution %}
31+
var i = 0;
32+
do {
33+
i++; // incrementing i by 1
34+
} while (i < 5);
35+
{% endexercise %}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.