convert celsius to fahrenheit in javascript

To convert Celsius to Fahrenheit in JavaScript, you can use the following formula:

index.tsx
function celsiusToFahrenheit(celsius) {
  var fahrenheit = (celsius * 9/5) + 32;
  return fahrenheit;
}
104 chars
5 lines

This function takes a temperature in Celsius as input and returns the temperature in Fahrenheit. Here's an example of how to use it:

index.tsx
var celsius = 25;
var fahrenheit = celsiusToFahrenheit(celsius);
console.log(fahrenheit); // Output: 77
104 chars
4 lines

In this example, we convert a temperature of 25 degrees Celsius to Fahrenheit and log the result to the console.

gistlibby LogSnag