HTML and CSS Reference
In-Depth Information
The following is an example of a multiline comment applied to a JavaScript program:
/*
ƒƒƒTheƒshowEM()ƒfunctionƒdisplaysƒaƒlinkƒtoƒtheƒuser'sƒe-mailƒ
ƒƒƒaddress.
ƒƒƒTheƒtextƒofƒtheƒuserƒandƒe-mailƒserverƒnamesƒareƒenteredƒinƒ
ƒƒƒreverseƒorderƒtoƒthwartƒe-mailƒharvesters.
*/
Inserting JavaScript Comments
• To insert a single-line comment into a JavaScript program, use
//ƒ
commentƒtext
where
commentƒtext
is the JavaScript comment. Single-line comments can be placed
on the same line as a JavaScript command.
• To insert several lines of comments, use the following structure:
/*
ƒƒƒcommentƒtextƒspanning
ƒƒƒseveralƒlines
*/
Kate would like you to add comments to the showEM() function you created.
To add comments to your JavaScript code:
◗
1.
Return to the
mpl.htm
file in your text editor.
◗
2.
Add the following multiline comment directly below the opening function state-
ment for the showEM() function:
/*
ƒƒƒTheƒshowEM()ƒfunctionƒdisplaysƒaƒlinkƒtoƒtheƒuser
'
sƒ
ƒƒƒe-mailƒaddress.
ƒƒƒTheƒtextƒofƒtheƒuserƒandƒe-mailƒserverƒnamesƒareƒenteredƒinƒ
ƒƒƒreverseƒorderƒtoƒthwartƒe-mailƒharvesters.
*/
◗
3.
Add the following single-line comment to the end of the line that reverses the
value of the userName parameter:
//ƒreverseƒtheƒtextƒofƒtheƒuserNameƒparameter
◗
4.
Add the following comment to the end of the line that reverses the value of the
emServer parameter:
//ƒreverseƒtheƒtextƒofƒtheƒemServerƒparameter
◗
5.
Finally, add the following comment to the end of the line creating the emLink
variable:
//ƒcombineƒtheƒtextƒofƒuserNameƒandƒemServer
Figure 10-27 displays these comments in the mpl.htm file.