Write temperature conversion and formatting functions.
Start building, submit solution and get feedback from the community.
2Submit Solution
5 upvotes10 upvotes
Temperature Converter
A temperature widget needs two conversion helpers and one formatting helper. Keep the math separate from the display text so each function has one clear job.
Write these functions:
celsiusToFahrenheit(celsius) should convert Celsius to Fahrenheit and return the number.
fahrenheitToCelsius(fahrenheit) should convert Fahrenheit to Celsius and return the number.
formatTemperature(value, unit) should return display text such as "77 F" or "20 C".