Comparisons, boolean logic, and conditions
Derive not started, learning, or completed from progress.
- Difficulty
- beginner
- Time
- 40 minutes
- Last verified
- 9/21/2026
What you will build
Derive not started, learning, or completed from progress.
Understand the idea first
Derive not started, learning, or completed from progress.
Build it step by step
function progressLabel(done, total) {
if (done <= 0) return '未开始';
if (done >= total) return '已完成';
return `学习中:${done}/${total}`;
}
console.log(progressLabel(3, 12));- Open the project from the previous lesson and record its current result.
- Type and run the example, then complete this task: Predict and test negative, zero, middle, exact-total, and over-total values.
- Change at least one input, predict the result, and verify it.
- Create and repair this lesson's typical failure: Do not confuse assignment with comparison; use strict equality and define boundaries.
Read the important lines
- Derive not started, learning, or completed from progress.
- Read the code as input, processing, and output; point to each part.
- A first successful run is not enough; verify a different input and an edge case.
Common mistakes and what to check
| Symptom | What to check |
|---|---|
| The result differs from the prediction | Do not confuse assignment with comparison; use strict equality and define boundaries. |
| Nothing changes after refresh | Save the file, verify the script path, and read the first relevant Console error. |
Practice without copying
Predict and test negative, zero, middle, exact-total, and over-total values.
Check the answer after you try
Rebuild it without copying and explain each decision. Key check: Do not confuse assignment with comparison; use strict equality and define boundaries.
Completion check
- I produced the required visible result
- I can explain the input, processing, and output
- I tested normal, edge, and failure cases