My code is working but how can I improve my code ? "Weather App"

I have got all the use cases to work, but my main concern is toggle temperature use case
It is working but is there a more professional/logical way it can be improved ?

I’m trying to avoid global variables as much as possible,

This is how it works:

  1. a request to the API is made

  2. the temperature ( in Celsius ) from the API request is saved to a global variable called “initialTemperatureFromServer”

  3. when the toggle button is clicked

  4. the value within the DOM #temp is saved as Celsius and converted to Fahrenheit

celsius = parseInt($("#temp").html());
  1. if the “#tempSymbol” == C, then the Fahrenheit is displays

  2. if “#tempSymbol” is not equal to C, then the original globak variable is called “initialTemperatureFromServer”

I think this is a very awkward way of doing this :roll_eyes::roll_eyes::roll_eyes:

Here is the code

what i did on mine was to generate the F and C then keep one hidden. when button is clicked show the hidden and hide the one thats shown.