Comments & Readability
Learn how to leave notes in your code and name variables clearly.
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`.