본문 바로가기
참고/JAVASCRIPT

if ~ else // if ~ else if 조건문

by Elfen Lied 2020. 5. 6.
반응형

*if ~ else 조건문

var num1 = 5;
var num2 = 4;

if (num2 > num1) {
    document.write("num1보다 큽니다.");
} else {
    document.write("num1보다 작습니다.");
}

값
num1보다 작습니다.

 

*if ~ else if 조건문

var num = 50;


if (num >= 90) {
document.write("A학점");
} else if (num >= 60) {
document.write("B학점");
} else if (num >= 50) {
document.write("C학점");
} else {
document.write("D학점");
}

값
C학점
반응형

'참고 > JAVASCRIPT' 카테고리의 다른 글

switch  (0) 2020.05.07
삼항 연산자 (if else 대체문)  (0) 2020.05.07
Prompt  (0) 2020.05.06
논리 연산자  (0) 2020.05.06
관계 연산자  (0) 2020.05.06

댓글