Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Astronauts</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
<h1>Astronauts</h1>
<div id="container">
<!-- List of astronauts will be added here dynamically -->
</div>
</body>
</html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Astronauts</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
<h1>Astronauts</h1>
<h2 id="count"></h2>
<div id="container">
<!-- List of astronauts will be added here dynamically -->
</div>
</body>
</html>
33 changes: 32 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
// TODO: add code here
// 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 +=`<div class="astronaut">
<div class="bio">
<h3>${astronaut.firstName} ${astronaut.lastName}</h3>
<ul>
<li>Hours in space: ${astronaut.hoursInSpace}</li>
<li>Active: ${astronaut.active}</li>
<li>Skills:${astronaut.skills}</li>
<li>Skills:${astronaut.skills.join(', ')}</li>
</ul>
</div>
<img class="avatar" src="${astronaut.picture}">
</div>`
counter++
}
let count = document.getElementById("count");
count.innerHTML = `<h3>Count: ${counter}</h3>`
container.innerHTML = astronauts;
})

})
})