Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello!

ID: 665702 • Letter: H

Question

Toggle navigation Home

This is a basic weather app that displays weather information and changes the background based on the type of weather.

Get started!

Enter Zipcode

Zipcode Close Submit

Current Weather Information (OpenWeatherMap.com)

Information Close $('#zip-btn').on('click', function (e) { //get data from zipcode field in modal var zipcode = document.getElementById("zip-code").value; //api key for openweathermap var apikey = "&APPID=85bbc4bccc488acb4223878d7437b1a9" //weather api format var weatherurl = "http://api.openweathermap.org/data/2.5/weather?zip=" + zipcode + ",us&units=imperial" + apikey; var xmlHttp = null; //forge http get request xmlHttp = new XMLHttpRequest(); // ("GET/POST, url, ASYNC/NO ASYNC") xmlHttp.open( "GET", weatherurl, false ); //send request xmlHttp.send(null); //200 = OK if (xmlHttp.status == 200) { //data returned as JSON, parse and store in weatherdata var weatherdata = JSON.parse(xmlHttp.responseText); //get weather information from parsed JSON data console.log("Zipcode entered: "+zipcode); console.log("URL used as GET request:"); console.log(weatherurl); console.log("Raw JSON data from request:"); console.log(weatherdata); console.log("Location: " +weatherdata.name); console.log("Temperature: "+weatherdata["main"].temp+"°F"); $('#weather-info tbody').append("Forecast:"+weatherdata["weather"][0].description+""); $('#weather-info tbody').append("Location:"+weatherdata.name+""); $('#weather-info tbody').append("Temperature:"+weatherdata["main"].temp+"°F"); $('#weather-info tbody').append("Humidity:"+weatherdata["main"].humidity+"%"); $('#weather-info tbody').append("Pressure:"+weatherdata["main"].pressure+" (hPa)"); $('#weather-info tbody').append("Wind Speed:"+weatherdata["wind"].speed+" mph"); $('#weather-info tbody').append("Lattitude:"+weatherdata["coord"].lat+"°"); $('#weather-info tbody').append("Longitude:"+weatherdata["coord"].lon+"°"); $("#weather").modal("show"); } else { console.log("Error! Request status: "+xmlHttp.status); } }) $('#weather-close').on('click', function (e) { $('#weather-info tbody').html(''); })

Explanation / Answer

543b0994926c9599aa4e2062a157e708c629b08a22468a8a0dcfc9400bbbd302

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote