CodeBloopers 1: Example 3

Debugging is Hard, Especially When Your Code is a Bloop

Example 3: The Case of the Missing Semi-Colons

Code:

if (x === 5) {
        console.log('Hello, World!');
      }

What's Going on?

This is an example of a common programming error. In JavaScript, semi-colons are not just for decoration. They are, in fact, required at the end of every statement. Without them, your code will be full of syntax errors.

Fix It

Simply add semi-colons where they are missing, like this: if (x === 5) ; { console.log('Hello, World!'); }

And that's it! You've fixed the bloop.

Related Articles:

The Case of the Missing Brackets

The Case of the Unterminated String