How to useArrow Function in Javascript
An arrow function provides a more concise way to define the conversion function. In this case, use the arrow function to convert Farenheit to Celcius.
Javascript
const fahrenheitToCelsius = fahrenheit => (fahrenheit - 32) * 5 / 9; let fahrenheit = 100; let celsius = fahrenheitToCelsius(fahrenheit); console.log(`${fahrenheit}°F is ${celsius}°C`); |
Output
100°F is 37.77777777777778°C
JavaScript Program to Convert Farenheit to Celcius
Converting temperature from Fahrenheit to Celsius is a common task in programming, especially when dealing with weather data or scientific calculations. In this article, we’ll explore how to create a JavaScript program to perform this conversion using different approaches.
The formula to convert a temperature from Fahrenheit to Celsius is:
Celsius = (Fahrenheit - 32) * 5/9
Where:
Celsius
is the temperature in degrees Celsius.Fahrenheit
is the temperature in degrees Fahrenheit.