01. 개념
if문 안에 if문을 또 사용하는 것
02. 사용법
if (조건식) {
if (조건식) {
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>중첩된 if문</title>
</head>
<body>
<script>
var score = Number(prompt("학생 점수를 입력하세요", "0~100 사이의 정수"));
if (score >= 0 && score <= 100) {
if (score > 80) {
alert("합격");
} else {
aleft("불합격");
}
} else {
alert("0~100사이의 정수로 입력하세요");
}
</script>
</body>
</html>
'웹 프로그래밍 기초 > 조건문' 카테고리의 다른 글
연습문제 1 (0) | 2025.04.08 |
---|---|
switch문 (0) | 2025.04.03 |
if else - if 문 (0) | 2025.04.03 |
if ~ else문 (0) | 2025.04.03 |
if문 (0) | 2025.04.03 |