Loading Depth Study
Preparing your workspace
Errors are problems that prevent code from behaving as intended, while debugging is the process of finding and fixing those problems.
Programs can contain syntax errors, runtime errors, logic errors, and incorrect assumptions. A good developer does not simply guess at the problem. They reproduce the issue, inspect the error message, check the relevant values, isolate the failing part, make a focused change, and test again. Debugging is a normal part of programming rather than a sign that someone cannot code.
If a checkout total is incorrect, inspect the input prices, quantity calculations, discount logic, and final calculation instead of changing random lines.
function divide(a, b) {
if (b === 0) {
throw new Error("Cannot divide by zero");
}
return a / b;
}
console.log(divide(10, 2));5