Skip to content

Commit f2f5147

Browse files
committed
Complete basic studio requirements - 26.6.2.3 Expected Results
1 parent 7d54ab1 commit f2f5147

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

script.js

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

0 commit comments

Comments
 (0)