Loading video player…

Debugging Code You Didn't Write (Overview)

You’re on the small tech team at The Second Draft, an independent bookshop, and bugs arrive the way they do at work. First, Grace, the owner, sends a note: a shelf count on the staff desk has gone below zero. Then a customer, Nadia, gets a refund that’s 150 pence short. Both bugs sit in code you didn’t write.

In this course, you’ll fix bugs, with evidence, in code a teammate or an AI agent wrote. For a first taste, here’s the check you’ll save for Nadia’s refund. It’s a small script that prints what you expected and what you got, and you run it with node ~/checks/refund.mjs. Before your fix, it prints this:

Language: Text
Expected: 600p
Actual: 450p

The shop refunds 450 pence where it should refund 600. After a one-line fix, the same check prints Actual: 600p, and the two lines agree. Before you put your name on the fix, you’ll also check that refunds on other orders still add up, since one passing check covers only Nadia’s order.

What You’ll Learn

By the end of this course, you’ll take a bug report to a bug that’s reproduced, explained and fixed, in a codebase you didn’t write. A saved check script will fail before your fix and pass after it. The course follows that route in order:

  1. Reproducing and Locating a Bug: Reproduce Grace’s bug and locate the fault.
  2. Asking the History When and Why: Ask the repo’s Git history why a line changed, and use your saved check with git bisect to find the commit that broke it.
  3. Fixing the Cause Safely: Fix the cause, and nothing more.
  4. Project: Nadia’s Short Refund: Fix Nadia’s refund, check that other refunds still add up, then explain your fix to Margaret, who built the refunds code.

What You Should Know Already

You need JavaScript basics, and you should already be able to read an error message and log a value. If either feels shaky, When Things Go Wrong: Errors and Debugging covers it.

From Finding Your Way Around a Codebase You Didn’t Write, you need to trace a feature and follow its data. The bugs land in the parts of The Second Draft you mapped there, so your map comes with you. The code is the copy of the shop’s GitHub repository you cloned in that course. If you’re starting here instead, the first lesson shows you how to get it. Node 26 and Git are the tools you need.

How the Course Works

Most lessons are text, and two more are videos like this one. Coding exercises run in your browser, and the course’s own tests check them. Your saved checks are different. They’re scripts you write yourself, and they print expected and actual. Code Mentor, RealJS’s AI mentor, answers your questions, and you check its answers. A quiz comes at the end.

There’s no download of the shop’s code. You work in your clone, and later lessons read its Git history. At the bottom of this page are the slides (PDF) and the sample code (ZIP). The lessons show each finished check, to compare with yours once you’ve written them.

Your first step is Grace’s note. Next, in Reproduce a Bug Report, you’ll make her shelf count go wrong every time.

Download

Course Slides (.pdf)

358.0 KB
Download

Sample Code (.zip)

1.2 KB

00:00 Welcome to Debugging Code You Didn’t Write. Here, you’ll fix bugs, with evidence, in code a teammate or an AI agent wrote.

00:10 For a first taste, here’s a saved check, a small script that prints expected and actual. For a refund, it shows 450 pence instead of 600. After a one-line fix, it shows 600.

00:26 You’re on the tech team at The Second Draft, an independent bookshop. Grace, the owner, reports a shelf count below zero. A customer, Nadia, gets a refund 150 pence short.

00:40 Can you put your name on the fix?

00:44 By the end, you’ll take a bug report to a bug that’s reproduced, explained and fixed. In the lessons, you’ll reproduce Grace’s bug and locate the fault, ask the Git history why a line changed, then fix the cause, and nothing more.

01:00 In the project, you’ll fix Nadia’s refund, check other refunds still add up, then explain the fix to Margaret, who built that code.

01:11 You need JavaScript basics, reading errors and logging values, and tracing a feature’s data from the last course. The bugs land in the shop’s code you mapped and cloned.

01:22 New here? The first lesson gets you the code. You’ll need Node 26 and Git.

01:29 Most lessons are text, and two more are videos like this one. Coding exercises are checked by the course’s tests. Code Mentor answers questions. A quiz comes at the end.

01:41 There’s no download of the shop’s code. You work in your clone, with its full Git history. Below this video are the slides and the sample code. The lessons show each finished check, to compare once you’ve written yours.

01:54 Next, in Reproduce a Bug Report, you’ll make Grace’s bug happen every time.

Become a Member to join the conversation.