[Intermediate] 조건문 If/Else

OROSY·2021년 3월 23일
0

JavaScript

목록 보기
14/53
post-thumbnail

1. 조건문

1) if문

지정한 조건이 참인 경우, 명령문(statement)을 실행합니다. 조건이 거짓인 경우 또 다른 명령문이 실행될 수 있습니다.

if (condition) { 
  statement1
}
else {
  statement2
}

condition:, 거짓으로 평가되는 표현식
statement1:
조건이 참으로 평가될 경우 실행되는 명령문
statement2:
조건이 거짓일 경우 실행되는 명령문

2) 다중의 if..else문

if (condition1) { 
  statement1
} else if (condition2) {
  statement2
} else if (condition3) {
 statement3
} else {
  statement4
}

출처: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/if...else

profile
Life is a matter of a direction not a speed.

0개의 댓글