Debug Intro
Debugging starts with a small reproducible failure. Check the input, trace the calculation, and compare the result with your expectation.
Where to run this
This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.
A practical example
const price = 6;
const quantity = "2";
console.log({price, quantity, type: typeof quantity});
console.log(price * Number(quantity));
What happens
The inspection reveals a string input before an explicit conversion produces 12.