Although you can create a workable outline document without JavaScript


Although you can create a workable outline document without JavaScript, JavaScript can improve upon the solution, if you put in a little work.
With JavaScript, you can keep the outline visible while the user reads the document, and you can make the outline much easier to navigate.

Using JavaScript, you can also make it easier for the user to quickly navigate


Using JavaScript, you can also make it easier for the user to quickly navigate the document outline. You can allow the user to hide irrelevant portions of the outline, leaving only the portions that are important to him or her.
You can do this by making the outline a dynamic document created on the fly instead of a static document loaded from the server.

Form modification is the process by which data entered by a user


Form modification is the process by which data entered by a user is translated into another format before being submitted to the form’s server.
When data from a form is submitted to its server, the data has to be formatted in a way that the server can understand. The format is usually in the form

<url>?<field1=value>?<field2=value>…

where <field1>, <field2>, and so forth are the NAME attributes of the INPUT, SELECT, and TEXTAREA elements of the form. The values are, with minor translations made by the browser, the VALUE attributes of those elements.

The TARGET attribute tells the browser to display


The TARGET attribute tells the browser to display the submission results in the viewer frame.

Without that, the results would replace the contents of the control frame, and the user would lose his or her view of the data.

In your work, you may need to write Web pages that talk to servers


In your work, you may need to write Web pages that talk to servers whose interfaces you have no control over. Two common kinds of servers are relational databases, which may require their input in SQL, and search engines like Alta Vista or Yahoo!. These interfaces may not meet the needs of your users, or they may be too complicated for your target audience.
Using JavaScript and the principle of form modification, you can create simple, easy-to-use interfaces that meet your user’s needs while satisfying the requirements of the server.

The big problem with the non-JavaScript solution is the enormous expense in bandwidth


The big problem with the non-JavaScript solution is the enormous expense in bandwidth. With every guess, a new HTML page is downloaded from the server. That’s a lot of traffic!

From the user’s perspective, this translates to a slow game. It’s okay for the user to deliberate about his or her next move, but the computer is expected to respond instantly! Instead, the user gets to watch the status bar display the number of seconds until the next page is downloaded.

The drawPlayingField() function is responsible for redrawing the playingfield frame


The drawPlayingField() function is responsible for redrawing the playingfield frame after each guess, as well as for drawing the initial frame. Like the displayScoreBoard() function you saw earlier, it creates a new HTML page and writes it to the playingfield frame.
However, it’s more dynamic than displayScoreBoard(): It uses the global variable score to determine how to draw the gallows and the hanged man, and it uses the guessedLetters array to determine which letters to fill in, and to display which letters the user has already guessed. While determining which letters to fill in, it also notes whether the user has guessed the word:

Although Javascript does not force you to declare or initialize variables


Although Javascript does not force you to declare or initialize variables before you begin function statements, it is often very useful to do so. First, it allows you to document the purpose of each variable. This is not only good programming practice, it is also genuinely useful.
When you return to a function six months after you wrote it you may not remember what the variable countme does, unless you explicitly document it as // array index variable. Second, if you explicitly declare each variable, then you have the opportunity to initialize them to some meaningful default value.

Functions, particularly ones that carry out critical tasks


Functions, particularly ones that carry out critical tasks like opening windows, should always check to see if their parameters are valid.
This usually involves making sure that they are the correct type and/or are within some expected range. First and foremost, then, we need routines to determine if the parameters are valid.

Strings are relatively safe as parameters, but numbers and booleans are not


Strings are relatively safe as parameters, but numbers and booleans are not. This is because JavaScript often converts a non-string, such as 5, to the corresponding string “5,” but it only converts to numerical or boolean values if it can.
If a string parameter is specified as the number 5, no error occurs, because the numerical value 5 and the string “5” may be freely converted to one another. If a numerical parameter is specified as the string “five,” an error very definitely occurs, because JavaScript does not know how to convert that string to a number.