The script code may be placed almost anywhere in the document, but should be positioned such that it is interpreted before it is accessed. For example, if a JavaScript function is called from the BODY tag, the function should be defined ahead of the BODY tag so the browser knows it exists before it tries to call it. In some cases, the script needs to be placed in a specific location. Multiple SCRIPT tag sets are allowed inside a single document.
Remember that all JavaScript code is case sensitive!
Comments may be placed inside the JavaScript using either:
The syntax for JavaScript object references follows the standard dot structure:
Brace brackets are used to enclose blocks of related code, such as functions.
To write a line of text onto a page, use the "write" method associated with the the document object as follows:
This script must be placed at the location where the text is to be written, as shown below.
HTML may also be included in the text string to provide formatting of the output on the web page as follows: