Start the exercise
Extract the ZIP and open a terminal in the exercise directory on a machine with Node.js. Use the current official documentation to set up Claude Code.
Starting command
node --test invoice.test.mjs
Two of the three tests fail in the starting project. A 15 percent discount on 90.00 should leave 76.50.
git init, git add ., git commit -m "Exercise baseline" save a baseline. Then launch claude and paste the task below.
Bug-fix prompt
Find the discount bug in this folder. First run node --test invoice.test.mjs and explain why the tests fail. Make the smallest necessary change in invoice.mjs. Leave the current tests intact. Then rerun them and report the cause, the changed line and the before/after test results separately.
Verify the evidence yourself
- Review the changed lines with git diff. This exercise should change only the discount calculation.
- Run the same test command yourself. All three tests should pass.
- Record the test output, changed file and root cause.
Show the reference fix and test result
- const discountCents = Math.round(subtotalCents * discountPercent); + const discountCents = Math.round(subtotalCents * discountPercent / 100);
The reference run started with one passing and two failing tests. After the fix, all three passed.
Sources · Claude Code · How Claude Code works