Why comments?
Comments are notes in your code that JavaScript ignores. Use them to explain why something works a certain way — not what the code does (the code itself should be clear enough for that).Single-line comments
// start a single-line comment. Everything after // on that line is ignored.
- JavaScript
- Python
// instead of #.
Multi-line comments
/* */. Use these for explaining complex logic or temporarily disabling blocks of code.
JSDoc comments
JSDoc comments start with/** and describe functions, parameters, and return values. Your editor reads them and shows helpful tooltips.
calculateTotal anywhere in your code, VS Code shows the description, parameter types, and return type. This is especially valuable when working on a team.
JSDoc comments are optional but helpful. You don’t need to add them to every function — focus on public functions and anything with non-obvious parameters. When you later move to TypeScript, the type annotations handle much of what JSDoc does.
When to comment (and when not to)
What’s next?
You’ve covered the fundamentals — variables, data types, strings, and comments. Now let’s make your code reusable with functions.Functions basics
Write reusable blocks of code