Comments and Fixing Mistakes
Notes for humans and how to read errors
Code is read by computers, but it is also read by people, including you next week when you have forgotten what you wrote. To help, you can leave little notes called comments.
Writing comments
Anything after // on a line is ignored by the computer. It is just for humans.
// This line is a note and does nothing.
console.log("This line runs."); // notes can go at the end tooComments are great for explaining why you did something, or for temporarily turning off a line of code without deleting it.
Everyone makes mistakes
When code has a problem, JavaScript shows an error message. This is not the computer being mean, it is trying to help you find the issue.
A very common beginner mistake is forgetting the quotes around text, or misspelling a word like console. When you see an error, read it slowly and check the line it mentions.
Try it yourself
Run the code below. Try adding your own comment, and try removing the // from the third line to see what changes.
Press “Run code” to see the result.
Quick check
Q1 What happens to text that comes after // on a line?
Want to save your progress? It's free.
Create a free account