이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Making decisions
if (test) { ... }runs its block only when the test istrue.elsegives the path to take when the test isfalse.
English
let age = 20;
if (age >= 18) {
console.log("adult"); // → adult
} else {
console.log("minor");
}
English
Many paths with else if
- Add
else iffor more choices. JavaScript checks each test top to bottom. - The first test that is
truewins; the rest are skipped.

English
let mark = 72;
if (mark >= 70) {
console.log("A"); // → A
} else if (mark >= 50) {
console.log("B");
} else {
console.log("C");
}
탐색하기
어떤 분기가 실행될까요?
Tests are checked top-down; the 첫 번째 true one runs and the rest are skipped.
English
Watch out
- Put the test in
( )and the block in{ }. - Inside a test, compare with
===(day === "Sat"), never a single=.
English
Common mistakes
- The condition goes in
( )and the body in{ }. - Compare with
===.
English
Now you try
- Read the value, then choose with
if/else. - Press Check answer to test it.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
let n = 5. If n is greater than 0 log positive, otherwise log not positive. (It should log positive.)
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
let mark = 65. Log A for 70 or more, B for 50–69, and C for less. (It should log B.)
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
let n = 4. Log even if n % 2 === 0, otherwise log odd. (It should log even.)
출력을 보려면 '실행'을 클릭하세요.