HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptTip

Convert between Celsius and Fahrenheit in JavaScript

Submitted by: @import:30-seconds-of-code··
0
Viewed 0 times
javascriptandbetweenconvertcelsiusfahrenheit

Problem

In order to convert from Celsius to Fahrenheit, you can use the conversion formula F = 1.8 * C + 32.
<latex-expression>
</latex-expression>
Conversely, the conversion formula from Fahrenheit to Celsius is C = (F - 32) * 5 / 9.
<latex-expression>

Solution

F = 1.8 \times C + 32


</latex-expression>
Conversely, the conversion formula from Fahrenheit to Celsius is C = (F - 32) * 5 / 9.
<latex-expression>
</latex-expression>

Code Snippets

F = 1.8 \times C + 32
const celsiusToFahrenheit = degrees => 1.8 * degrees + 32;

celsiusToFahrenheit(33); // 91.4
C = (F - 32) \times \frac{5}{9}

Context

From 30-seconds-of-code: convert-celsius-fahrenheit

Revisions (0)

No revisions yet.