Often these types of comments are placed at the top of a file, or before a particularly complex code block. Do not leave snippets of commented out code in your final script.
Creating Multi-line Comments Although a single line comment is quite useful, it can sometimes be burdensome to use when disabling long segments of code or inserting long-winded comments.
Commenting out code should only be done during testing purposes. Scripts that are small or that run only on one page can work fine within an HTML file, but for larger scripts or scripts that will be used on many pages, it is not a very effective solution because including it can become unwieldy or difficult to read and understand.
Quite often text editors have the ability to comment out many lines of code with a simple key stroke or option in the menu. Taking the time to leave proper annotation on complicated sections of code will pay dividends in the future, making it easier for you and collaborators to understand the intent of the code you have written.
Not only will this help you remember it later on, but if you someone else views your code, they will also be able to understand the code hopefully! As this is not a robust HTML document, you likely will not notice any difference in the loading of the page.
Block Comments Block-level comments, or multi-line comments, are long-form annotations used to introduce and explain a section of code. Another great thing about comments is the ability for comments to remove bits of code from execution when you are debugging your scripts. This is referred to as "commenting out code".
Commenting your code early on will reinforce good programming habits throughout your career to avoid these issues later on. Outdated comments can be more of a detriment than no comment at all, so remember to maintain and update comments regularly along with everything else.
An alert box is often used if you want to make sure information comes through to the user.
When an alert box pops up, the user will have to click "OK" to proceed. Syntax. mint-body.com("sometext"); The mint-body.com() method can be written without the window prefix.
Using comments to prevent execution of code is suitable for code testing. Adding // in front of a code line changes the code lines from an executable line to a comment.
Third and finally, in your alert statement itself, you neglected to include a semicolon. That and that alone can sometimes be enough for your code not to run as expected.
Notice that you can begin a comment after the code in a line, as shown in the line with the alert() Sometimes you have more than one or two lines worth of comment to write. In Here’s an example of a multi-line comment.