From 2c5348276d4e00ef3f45475f4f29bd600ad04c3f Mon Sep 17 00:00:00 2001 From: SandeepKumar1995 <54086388+SandeepKumar1995@users.noreply.github.com> Date: Sat, 10 Apr 2021 00:17:08 -0400 Subject: [PATCH] Update script.js --- script.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 9417030..65f5593 100644 --- a/script.js +++ b/script.js @@ -1 +1,32 @@ -// TODO: add code here \ No newline at end of file +// TODO: add code here +window.addEventListener("load",function(){ + fetch("https://handlers.education.launchcode.org/static/astronauts.json").then(function(response){ + console.log(response) + response.json().then(function(json){ + console.log(json); + let astronauts = ""; + let counter = 0; + let container = document.getElementById("container"); + for(astronaut of json){ + console.log(astronaut); + astronauts +=`
+
+

${astronaut.firstName} ${astronaut.lastName}

+ +
+ +
` + counter++ + } + let count = document.getElementById("count"); + count.innerHTML = `

Count: ${counter}

` + container.innerHTML = astronauts; + }) + + }) +})