<!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>Document</title>
</head>
<body>
<h1>3의 배수인지 아닌지 확인!</h1>
<p>숫자를 입력해주세요 ! </p>
<input type="number" id="checkNum"> <br>
<button id="checkBtn">확인하기</button>
<h1>공인중개사시험결과</h1>
1차시험<input type="number" id="firstTest"><br>
2차시험<input type="number" id="secondTest"><br>
<button id="acceptanceStatus" onclick="합격여부()">합격여부확인</button>
<script>
document.getElementById('checkBtn').addEventListener('click',function(){
if(document.getElementById('checkNum').value % 9 === 0 ){
alert('짝짝!')
}else if(document.getElementById('checkNum').value % 3 === 0){
alert('짝!')
} else{
alert('크크루삥뽕!')
}
})
function 합격여부(){
if(document.getElementById('firstTest').value < 40 || document.getElementById('secondTest').value < 40){
alert('최소 한과목과락!')
} else if(document.getElementById('firstTest').value+document.getElementById('secondTest').value >= 120){
alert('합격! ')
} else{
alert('불합격! 공부하세요 ㅜ ')
}
}
</script>
</body>
</html>
저는 이런식으로 코드를 작성했습니다.
공인중개사 시험 합격여부를 결과를 받아서 실행하게끔 했는데
40 || 40은 잘 되는데
document.getElementById('firstTest').value+document.getElementById('secondTest').value >= 120
여기서 두 값의 합이 120이 안나오는데도 else로 넘어가지 않고 alert창에 합격!이 뜨더라구요.
뭐가 문제여서 else로 넘어가지 않고 합격이 뜨는건지 알 수 있을까요?