JS 반복문 중첩 (for 문)
2021. 7. 16. 15:13
728x90

< 2단부터 9단까지 출력 // while 문 이용 >

|
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>반복문 중첩</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script>
//2~9까지 출력
for(dan = 2; dan < 10 ; dan++){
document.write(`<h2>---${dan}단---</h2>`);
//1~9까지 곱한 결과를 출력
for(i=1; i<10; i++){
document.write(`${dan} * ${i} = ${dan*i}<br>`);
}
}
document.write(`<hr>`);
</script>
</head>
<body>
</body>
</html>
|
cs |
728x90
'JavaScript > Study' 카테고리의 다른 글
| JS 제어문 (continue) (0) | 2021.07.16 |
|---|---|
| JS 조건문 (if 문) (0) | 2021.07.16 |
| [JS] 반복문 중첩 (while 문) (0) | 2021.07.16 |
| JS 반복문 (for 문) (0) | 2021.07.16 |
| JS 반복문 (do / while 문) (0) | 2021.07.16 |



