JavaScript Comments
Comments are notes for people. The computer skips them.
They help you remember why you wrote something.
Think of sticky notes on a toy box. The toys still work. The notes just explain.
Single line comments
Multi line comments
When comments help
When comments get in the way
Single line comments
Start a short note with //.
Everything after that on the same line is ignored.
Multi line comments
Wrap longer notes in /* and */.
You can write many lines inside.
Explain why, not only what
Code already shows what happens.
A good comment explains the reason.
Why did we choose this number? Why this name?
Turn code off for a moment
You can comment out a line while you test.
That is like covering a light switch with tape for a minute.
Keep comments fresh
Old comments that lie are worse than no comments.
If you change the code, update the note too.
Tip: Write comments for the next learner. Future you counts as a learner.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.