Coding Article Detail

post featured image

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 2022

Last updated 1 year, 10 months ago
Category: JavaScript
1 0

Back to Coding Articles

Comments: 0

There is no comments

Would you like to leave a comment?. Already have an account? Then please Sign In

If you don't have an account please Sign Up to create one.