Suggested solutions to these questions can be found in Appendix A.
degFahren = 9 / 5 * degCent + 32
Save this as ch02_q1.htm.
We get the degrees centigrade the user wants to convert by using the prompt() function, and store it inside the degCent variable.
We then do our calculation, which uses the data stored in degCent and converts it to Fahrenheit. The result is assigned to the degFahren variable.
The following code uses the prompt() function to get two numbers from the user. It then adds those two numbers together and writes the result to the page.
However, if you try the code out, you'll spot that it doesn't work. Why not?
Change the code so that it does work.
Save this as ch02_q2.htm.
The general rule is that where we have expressions with only numerical data, the + operator means "do addition." If there is any string data, the + will mean concatenate.