Question
Can you please add error checking for erroneous Fahrenheit values in HTML using the code. Below is the code and some notes provided. Thank you:
Can you please add error checking for erroneous Fahrenheit values in HTML using the code. Below is the code and some notes provided. Thank you:
JavaScript Celsius to Fahrenheit and vice-versa program
Insert a number into one of the input fields below:
degrees Celsius
degrees Fahrenheit
Note that the Math.round() method is used, so that the result will be returned as an integer.
Notes:
-
The two lines that start with
a. After the user clicks in a textBox, which constitutes an event, each subsequent keystroke (actually onkeyup events) causes the capital letter (C or F) to be passed to the convert() function
b. The convert() function then obtains the value in the textBox, via document.getElementById(XX).value, where XX is either the passed string C or F
-
Typing is implicit, but type can be determined at runtime see code below
-
C, F, and john are strings in JavaScript see code below
-
EXERCISE: Update the program above to add error checking for erroneous Fahrenheit values
-
The const statement sets a constant
-
If a value below absolute zero is entered into the Celsius text box, the Fahrenheit box is set to Invalid Temperature
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started