JavaScript JavaScript Basics Introducing JavaScript The Console Challenge Answer

Ruben Tugnolo
Ruben Tugnolo
8,096 Points

Workspaces

Hi! I would need a quick answer. Why I don't see any error in google chrome console when I run this code even if in line 1 and 6 is semicolon missing?

console.log("Start program") alert("Help me fix this program!"); alert("Can you get this message to appear?"); document.write("<h2>My first JavaScript program</h2>"); document.write("<p>I'm practicing 'debugging'.</p>"); console.log("End program")

Thank you.

1 Answer

The semicolon in JavaScript is used to separate statements, but it can be omitted if the statement is followed by a line break (or there’s only one statement in a {block}). A statement is a piece of code that tells the computer to do something. The semicolon is only obligatory when you have two or more statements on the same line. You can read more here