From 1dad81356c3c1bf5f939b50dbcd456d265783906 Mon Sep 17 00:00:00 2001 From: Jamar Taylor Date: Sun, 31 Jan 2021 23:01:21 -0500 Subject: [PATCH] part 1 --- .DS_Store | Bin 0 -> 6148 bytes index.html | 6 ++++-- weather.js | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .DS_Store create mode 100644 weather.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..57f5934a232150773f5c6d9f22b5b6e9f0fe53d4 GIT binary patch literal 6148 zcmeHK&2AGh5FV!~c!Ll*Akj;uy>P3d^hZS;Ds4l0=%Er~D|%>AyURw+O51gn-4Gy6 zwXacLg6HTH@Hp^|?M5Um*9eeD8h_*Qj4gj&**ioeI>Th0s7XW;%2@NzJRm&IdQWQB zvkVkG$9|?h#+i!I=Lwzs{S5Hg)hVS5I;Udp{B|+c`l&^4WEvNbic5RWxAA3`7G=Br zL)4b)%a0yQ*^rH=jSpd8jlwc2heanE9CPn&RQ6+QA1aki?I?bq_C}}8=WkSAMrqy~ z=;So%A>`yJ%@Z~1s9~NIdY;e>Na;!Mw7D`KZ)~^M{LQUblQn<*dIR>>=JsUb$rmrz zclOUNzI+{DO|EauSqOZnTAo?FgKsdV8~hXw@=WFD@Ns+t1m%=ak3Lh2`c#6hY>uq& zi2I!^kKWN9?NXNxfGuPsvl(J_E(2XBjseGjV_-21*sD-JSZ=2dE&+gbxV6C6zy3g<9l*e1We^^SFsVS3Dr|`%Y~>(KI>rMVUl}y%B=pLd z$F3}Fg(7U>A$%Q9A~5J$$ADvCmVqVHZSwoS_viY5Hp%rI1CD|JiUCpYhTRUfWZ%|% wo8!0Ehn_)MIIc1{O@X1GV#M-OyaLq%zt09Ruvi&{2jYGNG!3qC3@ns^U%-cTVE_OC literal 0 HcmV?d00001 diff --git a/index.html b/index.html index 3233671..abc3a20 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,11 @@ - Document + Weather App -

Hola Mundo

+

Weather App

+

+ \ No newline at end of file diff --git a/weather.js b/weather.js new file mode 100644 index 0000000..06901fa --- /dev/null +++ b/weather.js @@ -0,0 +1,19 @@ +// step 1 - create response object +let zipCode = new XMLHttpRequest(); +let zip = prompt("enter zipcode to get city & state"); + + +// step 2 - create call back + zipCode.onreadystatechange = function() { + if (zipCode.readyState === 4 && zipCode.status === 200) { + let response = JSON.parse(zipCode.responseText); + console.log(response); + let city = response.places[0]["place name"]; + let state = response.places[0]["state abbreviation"]; + document.getElementById('location').innerHTML = city + ", " + state; + } + } +// step 3 - create an open request + zipCode.open('GET', `http://api.zippopotam.us/US/${zip}`); +// step 4 - send the request + zipCode.send(); \ No newline at end of file