Help with the Faherenheit to celsius button in the weather app

Help with the Faherenheit to celsius button in the weather app
0

#1

Hello campers!,

I am struck since a month in the weather app task, I cant do that the temperature change to farenheit to celsius when I click a button (I would like made that whent I click the F in the temperature but is optional).

I have two functions one change to kelvin to farenheit and other change kelvin to celsius, so I had tried used this conditional:

//$("#change").click(function () {
  //if (weather.temp == K2F) {return K2C }else{ return K2C }
//});

But dont work I think that the problem is that the function are not calling weather.temp and I dont know why. How I could solve this?

This is my codepen

Thank you


#2

K2F and K2C are functions, so weather.temp == K2F does not do what you think it is doing. The statement will evaluate to false, because weather.temp is undefined based on where you called it from (outside of where weather has scope) and K2F is an object.