How to Convert Celsius to Fahrenheit (with code)
To convert a temperature from Celsius to Fahrenheit in JavaScript, you can use the following formula:
F = C * 9/5 + 32
Where F is the temperature in Fahrenheit and C is the temperature in Celsius.
Here's an example of how you can use this formula to convert a temperature from Celsius to Fahrenheit in JavaScript:
function convertCelsiustoFahrenheit(celsius) {
return (celsius * 9 / 5) + 32;
}
let celsius = 180;
let fahrenheit = convertCelsiustoFahrenheit(celsius);
console.log(celsius + '°C is equal to ' + fahrenheit + '°F');
This will output the following to the console:
180°C is equal to 356°F
By joseguerra on Tue 29 Nov 2022Last updated 1 year, 10 months ago
Category:
JavaScript
1
0