Checkpoint: Weekly Goal

The Course
•
3 min read

Your 15-minute checkpoint

Close the earlier examples. Spend two minutes writing the inputs, expected outputs, and steps in plain language. Use about eight minutes to build and test, then five to explain your choices and try the variation. Taking longer is normal: these are study budgets, not speed tests.

Combine repetition, decisions, and state. This problem deliberately changes the setting so you practise choosing the tools yourself.

A small warm-up

Before the main task, predict this familiar idea from today’s work. If it is unclear, revisit the relevant teaching lesson first.

Check the foundation

Say why each line appears, not just what it prints.

Check the foundation JavaScript
let count = 0;

for (let n = 1; n <= 3; n++) {
  count += 1;
}

console.log(count);
Check your prediction
3

Use this only as a warm-up. The main task needs you to combine several decisions.

Acceptance cases before you code

Write a small test plan before implementing weekly total at the threshold. These cases extend the brief; they are not a second worked solution. Predict the expected behavior independently, then test through the public function. A good ordinary example and a good boundary example should catch different possible mistakes.

Case to tryWhat your result should demonstrate
Goal exactly equal to the calculated totalReport reached
Goal one minute above the totalReport not reached
No days in a bounded rangeLeave the accumulator at zero

After the core task passes, deliberately break one rule and identify the case that notices it. Restore the implementation and explain the failure in terms of the contract, not the number of assertions. If a case requires a concept you have not recalled, revisit the relevant lesson before opening the solution.

Exercise

A weekly practice target

Practise 10 minutes on days 1–3 and 20 minutes on days 4–7. Print the total and whether the 100-minute goal is met. Derive the answer with a loop.

Your working space JavaScript
let total = 0;
// Visit days 1 through 7.
Hint 1: the idea

Choose the duration inside the loop, then update one total.

Hint 2: a first step

Use day <= 3 to distinguish the two schedules.

Show one solution
let total = 0;

for (let day = 1; day <= 7; day++) {
  if (day <= 3) {
    total += 10;
  } else {
    total += 20;
  }
}

console.log(total);

if (total >= 100) {
  console.log("Goal met");
} else {
  console.log("Keep practising");
}
110
Goal met

Change the goal to 110 and then 111. Explain the boundary before running. A second loop is unnecessary.

Change the requirements

Change the goal to 110 and then 111. Explain the boundary before running. A second loop is unnecessary.

Decide what to revisit

  • Can you explain each variable and the reason for each condition?
  • Did you check an empty, boundary, or changed input rather than only the supplied one?
  • Can you rebuild the essential part after closing the solution?

If you needed a hint, record the specific missing idea and revisit that lesson. Marking a page done records progress; it does not replace practice. Begin tomorrow by rebuilding one small part from memory.

Was this article helpful?

Your response is saved on this device.