![]() Putting Comments in ScriptsIt's a good idea to get into the habit of adding comments to your scripts. You do this by inserting comments that JavaScript won't interpret as script commands. While your script may seem perfectly clear to you when you write it, if you come back to it a couple of months later it may seem as clear as mud. Comments help to explain why you solved the problem in a particular way. Another reason to comment your script is to help other people who may want to re-use and modify your script. Script 2.4 shows examples of two kinds of script comments. The first kind is for longer, multi-line comments. The second example shows how to do single-line comments. Script 2.4. Here's how you can annotate your script with comments, which helps you and others understand your code.Note that we haven't included the HTML for this example, as it is the same as Script 2.2. From now on in the book, when the HTML hasn't changed from a previous example, we won't be printing it again. To comment your script: ![]() |