2 · Make decisions · 8 MIN
Choose a path
Conditions choose which instructions run.
An if statement runs its block when the condition is true. An else block handles the other case. >= means greater than or equal to. A return finishes the function immediately, so an early return can keep a decision simple.
A door opens if your ticket is valid. Otherwise, it stays closed.
Read the example
const score = 70;
if (score >= 60) {
console.log("Pass");
} else {
console.log("Try again");
}Check the expected output
Pass
Your challenge
Return "Pass" for scores at least 60; otherwise return "Try again".
Common trap
Using > 60 incorrectly rejects a score of exactly 60.
Next lesson: Read and fix an error →