DEV Community

Harshit Kedia
Harshit Kedia

Posted on

1

Created a Weather web app using HTML, CSS and Javascript

Basic idea is, we have an input field and submit button in a div, styled with CSS. Clicking the submit button invokes a function which inputs the city using document object model (DOM) query selector and we fetch an API with API key and city name as a query. Relevant data is extracted and displayed with a CSS styled div again selected using DOM.

Link of the weather app: https://weather-app-using-html-css-and-javascript.vercel.app/

We have an error display message which is styled as display: none by default, and is changed to display: block if the fetch method returns a 404 response, if the user enters an incorrect city name.

We also have an associated image displayed corresponding to the weather, which the instructor selected using if-else statement based on the weather property returned by the API, however, I used string interpolation with placeholder ${} to use the weather property to output file names directly, somewhat like images/${weather}.png and thus improved the code efficiency.

Link of associated code: https://github.com/Harshitnitw/Weather-App-using-HTML--CSS-and-Javascript

Thanks to GreatStack youtube channel for providing the learning experience: https://youtu.be/G0jO8kUrg-I?si=PxYmpNP420Et9LAp

Feel free to reach me out if you would like to learn and grow together 😄

Image description

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay