• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>JavaScript Iteration Statement</title>
7
</head>
8
​
9
<body>
10
​
11
    <h1>do / while 문</h1>
12
​
13
    <script>
14
        var i = 1, j = 1;
15
        
16
        while (i > 3) { // 변수 i의 초기값은 1이기 때문에 이 while 문은 한 번도 실행되지 않음.
17
            document.write("i : " + (i++) + "<br>");
18
        }
19
        
20
        do { // 변수 j의 초기값은 1이기 때문에 이 do / while 문은 단 한 번만 실행됨.
21
            document.write("j : " + (j++) + "<br>");
22
        } while (j > 3);
23
    </script>
24
    
25
</body>
26
​
27
</html>