Use the console and debugger to observe program state.
- console.log
- breakpoints
- step over
- watch expressions
The console shows messages and errors. Breakpoints pause execution at a line so you can inspect variables, follow control flow, and test assumptions. Reproduce a problem before changing code.
Adding more code without reading the first error usually hides the cause.
Set a breakpoint before a calculation, predict its result, step through it, and record the observed values.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.