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:
-
a request to the API is made
-
the temperature ( in Celsius ) from the API request is saved to a global variable called “initialTemperatureFromServer”
-
when the toggle button is clicked
-
the value within the DOM #temp is saved as Celsius and converted to Fahrenheit
celsius = parseInt($("#temp").html());
-
if the “#tempSymbol” == C, then the Fahrenheit is displays
-
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
Here is the code