<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>반복문</title>
</head>
<body>
<script>
let count = 0;
while(count <10){
console.log(count);
count++;
}
</script>
<script>
//구구단 3단 출력
let dan = 3;
let cnt = 1;
while(cnt <= 9){
// console.log(dan,'X',cnt,'=',dan*cnt);
console.log(`${dan} X ${cnt} = ${dan*cnt}`);
cnt++;
}
//----------------------------------------------------------
cnt = 1;
do{
console.log(`${dan} X ${cnt} = ${dan*cnt}`);
cnt++;
}while(cnt<=9);
</script>
</body>
</html>
'JS > JS 수업분' 카테고리의 다른 글
[JS] day09_이중반복문 (0) | 2023.04.18 |
---|---|
[JS] day09_whileEx (0) | 2023.04.18 |
[JS] day09_조건문 (0) | 2023.04.18 |
[JS] day09_Math_random (0) | 2023.04.18 |
[JS] day11_Lotto과제 (0) | 2023.04.18 |