thecodezone.
The Code Zone
← Back to the Developer Playbook

Code Zone Bug Lab / Episode 15

The Delete Button That Removes the Wrong Task

Rob deletes Build. Test disappears instead.

DEV-158 · Arrays · zero-based indices · splice15–20 minutesNo setup or account required
Deleting Build removes Test instead.
Deleting Build removes Test instead.

Your sprint ticket · In progress · DEV-158

The Delete Button That Removes the Wrong Task.

Customer report: The Delete button removes the task after the one I selected.

Steps to reproduce

  1. Start with Plan, Build, Test.
  2. Click Delete Build.
  3. Reset and try deleting the first and last tasks.

Make a focused behavior fix. Styling and adding unrelated features belong to another ticket.

Acceptance criteria

  • Deleting Build leaves Plan and Test.
  • Deleting the first task removes Plan only.
  • Deleting the last task removes Test only.
  • Successive deletions keep targeting the displayed task.
  • Deleting the only task leaves an empty list.

Learning demo only. No real accounts, purchases, authentication, or external requests.

Reproduce → inspect → hypothesize → verify

Take the ticket.

Reproduce the bug before editing. Inspect the Console and the JS tab. Explain one hypothesis, change the relevant code, then use Check challenge below the editor. Test the full ticket, not only the starter example. Reveal hints one at a time if needed.

Checking account and saved lab work…

Sign in to sync across devices

Loading the JavaScript and HTML editor…

Pass the checks or make three attempts to unlock an explained example.

Ready to test? Choose “Check challenge” after investigating.

    Open starter in a separate tab

    Code and prediction notes recover in this browser and sync when signed in. Instructor examples stay separate. Reset replaces code, not prediction notes.

    One possible solution

    Compare this approach with your own. Opening it does not change your code or mark the exercise complete.

    The renderer already passes the correct zero-based index. Use tasks.splice(index, 1). Adding one shifts the target to the next item and cannot remove the final item. Verify first, middle, last, and repeated deletions.

    Try first. Reveal one clue at a time.

    Need a lead?

    1. Follow the index.

    The first array position is 0. What index does the clicked button pass?

    2. Check the splice start position.

    Adding one to a zero-based index selects the next item.

    3. Use the supplied index.

    Change splice(index + 1, 1) to splice(index, 1). Retest after the list rerenders.

    Your lab report

    Show your reasoning.

    “I expected… I observed… The console showed… My hypothesis was… I changed… I verified…”

    Use Check challenge for automated behavior checks. Passing checks are useful evidence, not a complete code review.

    Give others room to investigate: label solutions as spoilers.

    Share your lab report on SKOOL (new tab) ↗