Temperature Convertor
React.js
medium
30 mins
Build a temperature convertor using React that allows users to convert values between Celsius, Fahrenheit, and Kelvin.
Requirements
- An input field to enter a numeric temperature.
- Two Dropdowns to Choose From:
- The "From" unit (Celsius, Fahrenheit, Kelvin).
- The "To" unit (Celsius, Fahrenheit, Kelvin).
- A Convert button that triggers the conversion when clicked.
Important Notes
- The Convert button should remain disabled if:
- The temperature field is empty
- Either unit (From or To) is not selected
- When button is clicked, the conversion should:
- Get the input value and selected units (fromUnit and toUnit).
- Convert the value to Celsius as an intermediate step
- Convert from Celsius to the target unit
- Display the result as:
{input}{fromUnit}is{convertedValue}{toUnit}. ex. 45 Celsius is 113.00 Fahrenheit
- Display the final converted value rounded to 2 decimal places.
Testing Instructions
Please use the following data-testid attributes in your React component:
temperature-input→ for the temperature<input />from-unit→ for the "From Unit"<select />to-unit→ for the "To Unit"<select />convert-button→ for the "Convert"<button />
Reference UI

Preview what you need to build
Companies:
paytm
slack
spotify
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
