(SOLVED) Weather app - Why does click method only work once?

(SOLVED) Weather app - Why does click method only work once?


I am confused as to why the “click” jQuery method in my “Show the local weather” app only works with the first click?

Please see my Codepen example here:

If you click the button, it works fine the first time. I set a variable to “isCelsius” as a boolean to control the path of the if statement. If they convert to Fahrenheit, it is set to “false” so next time the button is clicked it should use the path of the if statement to change it back to Celsius.

But it looks like the click method only works on the first click and never again. Can anyone please explain why this is the case?

See the Pen One Click weather question by Trey (@treytitone) on CodePen.


Look at the following if statement and see if you don’t see something wrong with the comparison syntax.

 if(isCelsius = true){

Hint: = assigns a value to a variable


Ah, silly mistake. As soon as I changed to:

 if(isCelsius === true){

It worked! Thank you.