"show the local weather" C - F switch issue


#1

I can’t get my switch to work. I might be approaching it a completely wrong or stupid way. So all suggestions are appreciated.


#2

I think its because your switch.click and modifyweather functions are defined in ajax call, would be better to make them global as well as finalTemp, tempC and tempF.


#3

It seems that both of your if conditions are being evaluated true or the function on clicking the button is being called twice.
I have tried logging in the console and am still trying to figure out the solution.


#4

@kasiraket you wont believe how silly was it!:joy:
Instead of the .switch in the selector use .slider as the selector and initialise the varClick as -1 and voila it will work.
The reason is because .switch is a label and therefore it every time you click on the slider the function was being executed twice.


#5

Thank you, I honestly don’t think I would’ve tried that!