HTML and CSS Reference
Although we haven't formally covered if statements, we have used them in several
examples, and they should be easy to follow. (See Chapter 6, “Under Certain Con-
ditions,” for a formal introduction). If the value of temp is equal to 98.6 , then the
following block of statements will be executed.
If is the user entered 98.6, the alert box sends the message “ Your temp is normal ”
to the browser.
If line 3 is not true, the block of statements following else is executed. An alert box
will appear in the browser window saying, “ You are sick! ” (see Figure 5.26).
Figure 5.25 User enters a string. The parseFloat() function will convert it to a
Figure 5.26 Output from Example 5.16.
the execution. 3 If there is no result, undefined is returned.
eval("(5+4) / 3");
3. The eval() function takes a primitive string as its argument, not a String object. If a String object is used, it
will be returned as is.