Console Debugging Lesson

### Concept Console debugging means printing information while a program runs so the developer can see what is happening. The console can show variable values, confirm that a function ran, or reveal which branch of a condition was chosen. Console logs are most useful when they are placed near the problem being investigated. A clear label in the message makes the output easier to understand when several logs appear at once.
### Code

Code Runner Challenge

Console Debugging Lesson

View IPYNB Source
%%js

// CODE_RUNNER: Console Debugging Lesson

function updateScore(score, points) {
  console.log("Before update:", score);
  score = score + points;
  console.log("After update:", score);
  return score;
}

updateScore(20, 5);
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

The logs show the value before and after the update. If the result is wrong, the developer can see where the value changed.