You have comments where they are needed. Some general rules are that you
should have a comment at the beginning of every function describing what that
function does, you should comment pieces of code that are particularly
difficult to understand, and you should have a comment at the very beginning
of the program explaining what the program does. The idea is that someone
looking through your code should be able to understand immediately how your
program does what it does. Here is the syntax for comments in JavaScript:
// This is a single line comment.
/** This is a multiple line comment.
* It's good style to put an * at the beginning of every line,
* as I have done.
*/