Debugging errors

Hey ,

I'm thrilled to help you learn JavaScript. Unfortunately, you've landed on a page where you cannot access with your current purchase.

Please upgrade (use this link) access this content.

I'm super eager to help you learn more!

Debugging errors

You will make errors when you code. And no, it doesn’t matter whether you’re a novice or an expert. Even experts make errors.

The difference?

When a novice encounters an error, they panic. Their minds go blank. They refuse to believe that their logic was wrong. They insist their code “should” work.

Experts, on the other hand, recognize that errors are part and parcel of programming life. Something has definitely slipped their minds if they encounter an error. They use the opportunity to find and fix the error.

To become a good developer, the #1 skill is to be able to figure out what went wrong, and make the necessary adjustments. This is a process known as debugging.

How to debug

Watch this video. I’ll show you how to debug in 5 minutes :)

Exercise

Are there any errors with the following code? If yes, find out what they are and fix them.

<a class="button" href="#">Link that looks like a button</a>
const button = document.querySelector('button')

button.addEventListener('click' e => {
  console.log('Button clicked!'))
})