HTML and CSS Reference
In-Depth Information
document.write("</em><br />After a 10 point bonus, your grade "
+ is grade + "!<br />");
The user is prompted to enter a grade. The string value entered in the prompt box
is assigned to the variable grade (see Figure 5.23).
The parseInt() function will convert the grade to an integer value.
The typeof() operator returns the data type of the variable grade .
The value of grade is incremented by 10.
The new value of grade is sent to the browser (see Figure 5.24).
Figure 5.23 The user enters a grade.
Figure 5.24 The new value of grade is displayed in the browser.
5.3.2 The parseFloat() Function
The parseFloat() function is just like the parseInt() function except that it returns a float-
ing-point number. A floating-point 2 number is a number that contains a fractional part,
such as 3.0, -22.5, or .15. The decimal point is allowed in the string being parsed. If the
string being parsed does not start with a number, NaN (not a number) is returned (see
Table 5.18).
2. The term “floating point” means that there are not a fixed number of digits before or after the decimal
point; the decimal point floats.
Search WWH ::

Custom Search