Java Reference
In-Depth Information
figure 2-6  
You pass two pieces of information to the prompt() function:
The text to be displayed—usually a question that prompts the user for input
The default value that is contained in the input box when the prompt dialog box first appears
These two pieces of information must be specified in the given order and separated by a comma. If you
don't want a default value to be contained in the input box when the prompt box opens, use an empty
string ( "" ) for the second piece of information.
As you can see in the preceding code, the text is “Enter the degrees in Fahrenheit,” and the default
value in the input box is 50 .
Next in the script block comes the equation represented in JavaScript. You store the result of the
equation in the degCent variable. You can see that the JavaScript looks very much like the equation you
have in the comment, except you use degFahren instead of °F , and degCent rather than °C :
degCent = 5/9 * (degFahren - 32);
Search WWH ::




Custom Search