Toggling between Fahrenheit and Celsius and back again

Toggling between Fahrenheit and Celsius and back again
0

#1

Okay, so I’ve got a decent ways through the challenge with minimal frustration, but this one which seems like a simple task, is killing me. Three solid days of slow torture. Anyway, I’ve got the first part down where you can click of the red F and it changes to C and updates the temperature. It is the flipping back part that is the issue. I can’t for the life of me figure out how to do that. I’ve tried modifying various versions that I’ve seen around and none of them work like I want.

Here’s My Pen. Sorry for the bland background.


#2

Hi. I’m not sure your temperature is correct. It’s about 30 degrees cooler in my place than your site says.

I’m also not sure about your calculation. fahrenheit = Math.floor(celsius * (5/9) + 32);

I think it is (celsius * (9/5) + 32);
This site was very helpful to me when I worked on this project: http://www.rapidtables.com/convert/temperature/celsius-to-fahrenheit.htm

It looks like you have a function to toggle F to C. But I do not see a function to toggle C to F. I think you may need to tell it what to do on each temp toggle.


#3

There in lies my issue. I’m not even sure how to structure flipping it back to Fahrenheit once I get it to Celsius. Thanks for the heads up on the calc. I’ve been flipping so many things around the past few days I hadn’t even noticed it.


#4

I understand. It was not the easiest project for me, but I was very proud of my work once it was over.

All you need to do is check to see what the toggle is on. If it is on C then toggle to F, and if it is on F then toggle to C.

This could be inside one function. First check to see what it is. Then change it. Do that on each click.