ConvertersLesson 323Free preview
Convert Temperature
This lesson is part of How To · All levels
Summary
The temperature converter changes the values between Celsius, Fahrenheit, and Kelvin using a standard formula. JavaScript reads the input values, determines the source and destination units, and then writes the result to the output element. Validation is required so that empty or below absolute zero inputs do not result in a wrong answer.
Key points
- The formula for Celsius to Fahrenheit: (C × 9/5) + 32
- The formula of Celsius to Kelvin: C + 273.15
- Fahrenheit ke Celsius: (F - 32) × 5/9
- Absolute zero is equal to -273.15 degrees Celsius.
- Use parseFloat and check the NaN before you count.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.