JS 반복문 (do / while 문)
2021. 7. 16. 01:37
728x90

- do / while 문은 먼저 루프를 한 번 실행한 후에 표현식을 검사
표현식의 결과와 상관없이 무조건 한 번은 루프를 실행
do {
표현식의 결과가 참이 될 동안 반복적으로 실행하고자 하는 실행문;
} while (표현식);

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>do - while 예제</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script>
var i=10;
do{
document.write("Hello World<br>");
i++;
}while(i<5);
</script>
</head>
<body>
</body>
</html>
|
cs |
728x90
'JavaScript > Study' 카테고리의 다른 글
[JS] 반복문 중첩 (while 문) (0) | 2021.07.16 |
---|---|
JS 반복문 (for 문) (0) | 2021.07.16 |
JS 반복문 (while 문) (0) | 2021.07.16 |
JS 삼항 연산자 (표현식 ? 반환식1 : 반환값2) (0) | 2021.07.15 |
JS 논리 연산자 (&&, ||, !) (0) | 2021.07.15 |