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));
  1. Open the project from the previous lesson and record its current result.
  2. Type and run the example, then complete this task: Predict and test negative, zero, middle, exact-total, and over-total values.
  3. Change at least one input, predict the result, and verify it.
  4. 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

SymptomWhat to check
The result differs from the predictionDo not confuse assignment with comparison; use strict equality and define boundaries.
Nothing changes after refreshSave 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

Your privacy choices

Necessary storage is always on. Optional analytics and support services load only after consent.