Having trouble with conversion buttons on local weather app [Solved]

Having trouble with conversion buttons on local weather app [Solved]
0

#1

My conversion buttons on my local weather app are not working correctly. It switches from celsius to fahrenheit but it won’t switch back. Here is my pen http://codepen.io/johnwm211/pen/JKLNKw


#2

You have a typo in this area:

// you intended to refer to `.celsius-button`!
$(".celcius-button").on('click', function(e){
  e.preventDefault();
  $tempDisplay.html(cTemp);
});

#3

Also, I believe you have a conversion error from Fahrenheit to Celsius. I get 65°C for 83°F!

This is your code:

var cTemp = Math.floor((temp) - 32 * 5/9) + '&deg' + 'C';

The - 32 should be inside the parentheses with temp, like (temp - 32) * 5/9, so now I have 28°C for 83°F.


#4

I can’t believe I missed that! Thanks a lot @kevcomedia!