My Weather Application. Review Please!

Here is my weather application.Please tell me how it is. and if you can help me that how to include the state name in this application along with city.Link

Hi, @ShwetaRajput. You could make this such as it shows weather information on page load. You don’t have to request for location every time a user clicks °C or °F; you can just convert the temperature via JS.


BIG +1 on making sure it doesn’t do an API call with the temperature change. I would also add this to your body declaration in CSS:

background-repeat: no-repeat;
background-size: cover;

Looks great, otherwise! You seem to be plowing through these projects at a good pace.

1 Like

I did what you suggested. now you can check again.and please help if you can that how to add state and country name to it?

It does request for location at page load, but it’s still requesting when I click °F or °C.

You may want to refer to the documentation of the API that you used.

1 Like

Well i used the API request at °F and °C buttons so that we can see temperature in both f and c. Else i would have to create an conversion function.

A conversion function is definitely better than a new API call. You did the temperature conversion exercise in the challenges, right?

Yes i did. Okay will try.ThankYOU

Now you can have a look. And tell me if what i did is right or wrong?

Yep it works :thumbsup:!

1 Like

Thank You for the suggestions.They worked because of you only.

One more thing my weather app sometimes show my location, sometimes it show nearby location,or a location which is far away. Why That happens?

I’m not sure, to be honest (I haven’t started my weather app yet), but my guess is that it’s API-related.
In my case your weather app (and most weather apps I try that request for my location) gives me my neighboring town’s weather, but I don’t mind because I am closer to that town’s center than to my own town’s center.

1 Like

I am looking for a more efficient way to toggle between Celsius and Fahrenheit - this is my initial setup…

var f2c = [c + '\xB0' + " " + "Celsius", f + '\xB0' + " " + "Fahrenheit"]; var i = 0; $("#button").click(function (){ i = (i + 1) % f2c.length; $("#temp").html(f2c[i]);

It works but is there a better method?

What do you think about my code. I used different way.

for some reason- codeine will not let me use navigator.geolocation …