Skip to content

Commit 7765c01

Browse files
committed
initial attempt at studio
1 parent 7d54ab1 commit 7765c01

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</head>
99
<body>
1010
<script src="script.js"></script>
11+
1112
<h1>Astronauts</h1>
1213
<div id="container">
1314
<!-- List of astronauts will be added here dynamically -->

script.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
// TODO: add code here
1+
window.addEventListener("load", function(){
2+
let json = [];
3+
fetch("https://handlers.education.launchcode.org/static/astronauts.json").then(function(response) {
4+
console.log(response);
5+
response.json().then(function(json) {
6+
const container = document.getElementById("container");
7+
let index = 0;
8+
container.addEventListener("click", function(){
9+
container.innerHTML = `
10+
<div class = "astronaut">
11+
<div class = "bio">
12+
<h3>${json[index].firstName, json[index].lastName}</h3>
13+
<ul>
14+
<li>Hours in space: ${json[index].hoursInSpace}</li>
15+
<li>Active: ${json[index].active}</li>
16+
<li>Skills: ${json[index].skills}</li>
17+
</div>
18+
<img class="avatar" src="images/mae-jemison.jpg">
19+
</div>
20+
21+
`;
22+
index = (index + 1) % json.length;
23+
</div>
24+
});
25+
26+
});
27+
});
28+
29+
});

0 commit comments

Comments
 (0)