Exercise—Temperature Conversion JavaScript

  1. Consider the following example. This example is closely based on the example you looked at previously:

     <html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- Cloaking device on! function inputCels() { var cels = prompt("Enter a temperature in Degrees Celsius","Enter a temperature"); ansFah = doFahCalc(cels); alert(cels + " Degrees Celsius is " + ansFah + " Degrees Fahrenheit"); } function inputFah() { var fah = prompt("Enter a temperature in Degrees Fahrenheit","Enter a temperature"); ansCel = doCelCalc(fah); alert(fah + " Degrees Fahrenheit is " + ansCel + " Degrees Celsius"); } function doCelCalc(fah) { var ans = ((Number(fah) - 32) / 1.8); return (ans); } function doFahCalc(cels) ...

Get JavaScript™ 1.5 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.