Comments & Readability

Learn how to leave notes in your code and name variables clearly.

Step 1 of 3

What are comments?

As your code grows, it becomes harder to remember why you wrote something a certain way. Comments let you leave notes for yourself and other developers — JavaScript completely ignores them when running your code.

There are two styles of comments:

- **Single-line comments** start with `//`. Everything after `//` on that line is ignored. - **Multi-line comments** start with `/*` and end with `*/`. Everything between those markers is ignored, even across multiple lines.

You can also place a single-line comment at the end of a line of code to explain what that specific line does.

Beyond comments, the names you choose for your variables matter just as much for readability. JavaScript developers follow these conventions:

- **camelCase** for regular variables and `let` declarations: `firstName`, `totalScore`, `currentLevel`. - **UPPER_SNAKE_CASE** for constants that represent fixed, universal values: `MAX_RETRIES`, `API_URL`, `TAX_RATE`.

Think of it this way: Comments are like sticky notes you leave on your code — reminders for your future self.
Tip
Good variable names reduce the need for comments. `let x = 5;` is confusing — `let playerLives = 5;` is self-explanatory.
Learn more on MDN
JAVASCRIPTREAD ONLY
CONSOLE
Click "Run" to execute your code...