Javascript click function to convert from Fahrenheit to Celsius [on hold]

229
April 24, 2017, at 07:10 AM

I am trying to implement a button to convert the displayed temperature from Fahrenheit to Celsius and vice versa. I cannot figure out if I need to resend a request to the OpenWeather API or if I can just replace the F with a C in the convertTemperature formula on a click event and how I would go about doing that. Any advice is appreciated thanks!

Here is a link to my code http://codepen.io/jamesemcc/pen/KWavPy?editors=1111

Answer 1

There is no need of an external API just to convert Celsius to Fahrenheit as it is pretty standard.You can just use this formula:

T(°F) = T(°C) × 9/5 + 32

OR

T(°F) = T(°C) × 1.8 + 32
READ ALSO
Angular - Uniqueness validator in FormArray

Angular - Uniqueness validator in FormArray

I created a custom validator to validate uniqueness in my FormArrayI want to show error when specific(s) value(s) is/are already in array

359
Build Electron app

Build Electron app

I'm trying to build a setup file in Electron with electron-builder but it's always giving me an errorI'm running in the latest version on electron, npm and nodejs

475
How to change the image to another in canvas for some time and then change back again

How to change the image to another in canvas for some time and then change back again

I am new to game development and I am developing a simple game where I can get a point when I hit the monster by carSo now I want to change the color of the car (if red then blue and vice versa ) when I hit the monster for a while (5 seconds) and then switch...

203
Accessing params with react-router-redux

Accessing params with react-router-redux

I'm using react-router-redux (https://githubcom/ReactTraining/react-router/tree/master/packages/react-router-redux)

277