Comments
A comment is a note for people who read your code. JavaScript skips comments completely. There are two kinds:
//turns the rest of the line into a comment./*and*/turn everything between them into a comment, even across many lines.
// This whole line is a comment
console.log("runs"); // a note about this line
/* This block is skipped,
even though it has two lines */
console.log("also runs");
Output:
runs
also runs
What comments are for
Good comments explain why. For example, why you chose a value, or what to be careful about. Do not write a comment that only repeats what a line does. A clear name is better: totalPrice says more than tp with a comment next to it.
Comments have one more everyday use. You can switch a line off without deleting it:
// console.log("debug: reached step 2");
This prints nothing, because the whole line is now a comment. The line stays in the file, so you can bring it back later by removing the //. Programmers do this a lot while they look for mistakes.
Later you may see comments that start with /** above functions. These are still normal comments. Some tools read them to show help text in the editor.
In the exercise, comment out the leftover debug line (turn it into a comment), but do not delete it.