File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
1
window . addEventListener ( "load" , function ( ) {
2
- // let json = [];
3
2
fetch ( "https://handlers.education.launchcode.org/static/astronauts.json" ) . then ( function ( response ) {
4
3
console . log ( response ) ;
5
4
response . json ( ) . then ( function ( json ) {
6
- const container = document . getElementById ( "container" ) ;
7
- let index = 0 ;
5
+ let container = document . getElementById ( "container" ) ;
8
6
9
- // container.addEventListener("click", function() {
10
- container . innerHTML = `
7
+ for ( let index in json ) {
8
+ container . innerHTML + = `
11
9
<div class = "astronaut">
12
10
<div class = "bio">
13
11
<h3>${ json [ index ] . firstName } ${ json [ index ] . lastName } </h3>
14
12
<ul>
15
13
<li>Hours in space: ${ json [ index ] . hoursInSpace } </li>
16
14
<li>Active: ${ json [ index ] . active } </li>
17
15
<li>Skills: ${ json [ index ] . skills } </li>
16
+ </ul>
18
17
</div>
19
18
<img class="avatar" src="${ json [ index ] . picture } ">
20
- </div>
21
- ` ;
22
- index = ( index + 1 ) % json . length ;
23
- // });
19
+ </div>` ;
20
+ }
24
21
25
22
} ) ;
26
23
} ) ;
You can’t perform that action at this time.
0 commit comments