Switch button with jQuery (Fahrenheit / Celsius)

Hello, I’m struggling with the switch button in the local weather app. Firstly I just want that everything works, after that I’ll improve the look.

Here is my pen:

In the switch (at the bottom of the js file) I’m trying to get the html of my temp class. If it’s “Temp: " + tempF I want to replace it. I tried to “console.log $(”.temp”).html" but I can’t really get the inner HTML. What do I’m missing? What is wrong?

Hopefully somebody can help me out! :slight_smile:
Greetings

Hey just looked at the issue.

In the console it says “Uncaught ReferenceError: tempF is not defined” that is because tempF is a local variable to your $.getJSON.

So you will need to find a way to define tempF and tempC outside of the $.getJSON.

I don’t want to give you the answer so I hope that will help get you over that hump for now.

Edit:

Adding: basically other functions cannot see tempF or tempC right now. They do not even know it exist.

1 Like

Oh, amazing. Now it works.

Extremly dump mistake… Thank you!

Lol no problem. It happens to the best of us.

1 Like