Learning guides / AI coding courses

Coding practice · about 35 minutes

Reproduce a bug and keep a regression test

Use a boundary-date fixture to reproduce a defect, repair it and keep checks for the day before, at and after the boundary.

Is this the next skill you need?

Choose this if an assistant can produce a plausible fix but you cannot tell whether it addresses the reported failure. Look for debugging and testing practice in a course, rather than more setup lessons.

Preparation: You can read a JavaScript comparison and understand a failing assertion. Use Node.js 20 or newer; the exercise runs offline.

The time is our planning estimate for this small exercise, not a measured course completion time. If setup takes your whole session, save the command and error, then return after practicing the basics.

Your task and starter files

A fictional pass remains valid through its final numbered day. The implementation uses a strict comparison and wrongly rejects the final day. Days are integers, not timestamps; do not add date parsing or timezone behavior.

Download the original exercise ZIP

1,365 bytes · README, source, checks and reference answer. Extract the ZIP into one folder. Run the commands from that folder. No npm install or paid tool is needed.

node --test task.test.mjs

Expected initial result: Exactly one supplied code test fails; preserve all tests when repairing the code.

The examples are invented for learning. They are independent of provider courses and can be attempted without an AI assistant. If you use one, keep the requirement and supplied checks visible, then review its actual changes.

Work through it

  1. Run the unchanged tests and save the failure for final day 7.
  2. Write the reproduction: expires=7, today=7, expected=true, actual=false.
  3. Change only the comparison in task.mjs. Keep the contract: today must be less than or equal to expires.
  4. Rerun all three checks, then save the diff and the before-and-after output. Explain why day 8 remains invalid.

Check your result

Open the worked answer after your attempt

Use today <= expires. The three cases are day 6 true, day 7 true and day 8 false. The provided failing test is the regression check: preserve it when you repair the implementation.

The ZIP includes a reference implementation or reference JSON. Use it to compare your reasoning after an attempt; a copied answer does not show that you can perform the task independently.

Keep as evidence: the original observation, your changed code or completed worksheet, the exact command and output, and a short explanation of the decision. When tests begin with one failure, the same unchanged tests should all pass after the repair. For the refactor, checks should pass both before and after.

Scope: Integer day numbers deliberately avoid locale and timezone complexity. Passing this fixture does not validate a real subscription service or timestamp policy.

Choose a lesson from the gap you found

If the exercise was hard because you could not run the code, work on language and command-line basics first. If running it was easy but explaining the change was hard, focus on the matching workflow lesson and repeat with fresh inputs.

Cursor Learn has official material on understanding code, developing changes, debugging, and reviewing work. Claude Code 101 covers agent context and a structured coding workflow. Use those lessons for instruction and this independent fixture to check your own result.

Public lesson access and tool usage are separate. Check current pricing, account requirements and usage limits before using either tool. A paid course is most useful when its assignments address the specific step you could not complete.

Find courses for a coding-assistant workflow →

Check the starting skills · Check free and paid access · Choose Claude Code or Cursor first

Sources and authorship

Original AI Course Rank tasks and editorial learning recommendations, published 11 November 2026. Official learning topics checked on that date: Cursor Learn, Claude Academy. The Node.js test-runner documentation explains the built-in testing command. These small tasks are practice evidence, not validated assessments or tool performance comparisons.