JavaScript
Making decisions
A practical reference with examples you can run.
Introduction
A conditional chooses an action based on a true-or-false expression. Think about the boundary: does a score of exactly 10 belong in the first branch? Test values below, at, and above that boundary.
Syntax & example
const score = 12;
if (score >= 10) {
console.log("Ready for the next step!");
} else {
console.log("Keep practicing!");
}Expected output
Ready for the next step!
Common mistakes
- Using a variable before assigning a value to it.
- Mixing text and numbers without converting deliberately.
- Skipping an empty input or a boundary value when testing.
Practice
Change the score and test both branches.
main.jsYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-86 lines