Write temperature conversion and formatting functions.
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".
Sample checks:
Expected output:
The conversion functions should return numbers. formatTemperature should return the final string.
Join the Community
roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login or Signup
You must be logged in to perform this action.