Learning guides / AI coding courses

Coding practice · about 35 minutes

Turn a feature request into acceptance checks

Translate an ambiguous list-limit request into boundary cases and implement a small function under an explicit contract.

Is this the next skill you need?

Choose this when an assistant builds what you asked for but the result misses an unstated boundary. A suitable course should practice requirements, examples and tests before implementation.

Preparation: You can read arrays and integer comparisons. Use Node.js 20 or newer; there is no browser, API or external service in this task.

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

The request says “show only the first few results.” For this exercise the agreed contract is precise: limit is a nonnegative integer, limit zero returns no items, the original order is preserved, and the caller array stays unchanged.

Download the original exercise ZIP

1,523 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. Write expected outputs for limit 0, limit 2 and a limit larger than the list.
  2. Run the starter checks. Its limit || items.length shortcut treats zero as missing and causes one failure.
  3. Repair task.mjs under the declared integer contract. Keep the supplied tests unchanged.
  4. Save a short acceptance note with the input domain, the three boundary outputs and the mutation check. Name one behavior outside scope, such as negative limits.

Check your result

Open the worked answer after your attempt

Return items.slice(0, limit). For [A, B, C], limits 0, 2 and 9 produce [], [A, B] and [A, B, C]. The copy leaves the original array untouched. The acceptance examples decide the meaning of zero before any tool writes code.

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: Negative, fractional, missing and nonnumeric limits are outside the agreed input domain. If a real interface accepts them, decide their behavior and add checks before reusing this function.

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.