// Function to convert temperature from Celsius to Fahrenheit
function celsiusToFahrenheit(celsius) {
return (celsius * 9/5) + 32;
}
// Example temperature in Celsius
const temperatureInCelsius = 25;
// Convert the temperature to Fahrenheit using the celsiusToFahrenheit function
const temperatureInFahrenheit = celsiusToFahrenheit(temperatureInCelsius);
// Log the converted temperature to the console
console.log('Temperature in Fahrenheit:', temperatureInFahrenheit);
code
JavaScript Celsius to Fahrenheit Converter
This JavaScript code defines a function celsiusToFahrenheit that converts a temperature from Celsius to Fahrenheit using the conversion formula. The example temperature in Celsius (25) is then converted to Fahrenheit using this function, and the result is logged to the console. The comments provide explanations for each part of the code.
Temperature Conversion
Celsius to Fahrenheit