(Solved) Can't get Weather app to switch back to Celsius

Tried to mimic the example’s “switch button” (just one onClick - in this case, the letter itself - to change from C to F and from F to C again).

I was able to make it change from C to F, but the thing is: I just can’t make it change back.

I thought an else statement would be enough, but I was wrong. I think my logic is out. I’ve been trying for more than an hour now, but I don’t think I’m going anywhere with my trying & searching because I’m probably am persisting in an error.

Please, could you take a look at my code and help me?

I really need a light here :slight_smile:

Hey, I’m sorry I’m new to FreeCodeCamp so I don’t know how to use the forums correctly yet :smiley:
The problem was that you didn’t change the value of tempFormat, so the else clause was not executing since it was still assigned to the value of “C”.

$("#changeFormat").on("click", function(){
              if (tempFormat == "C") {
                var fahrenheit = tempNow * 9/5 + 32;
                tempFormat = 'F'; <------ Add this
                $("#changeFormat").html(" ºF");
              } else {
                tempFormat = 'C'; <---- Add this
                $("#changeFormat").html(" ºC");
1 Like

Omg, I knew it was a simple mistake, but I also wouldn’t have thought that this was the problem.

Now I can go to sleep in peace. Thank you so much.