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 11window . addEventListener ( "load" , function ( ) {
2- // let json = [];
32 fetch ( "https://handlers.education.launchcode.org/static/astronauts.json" ) . then ( function ( response ) {
43 console . log ( response ) ;
54 response . json ( ) . then ( function ( json ) {
6- const container = document . getElementById ( "container" ) ;
7- let index = 0 ;
5+ let container = document . getElementById ( "container" ) ;
86
9- // container.addEventListener("click", function() {
10- container . innerHTML = `
7+ for ( let index in json ) {
8+ container . innerHTML + = `
119 <div class = "astronaut">
1210 <div class = "bio">
1311 <h3>${ json [ index ] . firstName } ${ json [ index ] . lastName } </h3>
1412 <ul>
1513 <li>Hours in space: ${ json [ index ] . hoursInSpace } </li>
1614 <li>Active: ${ json [ index ] . active } </li>
1715 <li>Skills: ${ json [ index ] . skills } </li>
16+ </ul>
1817 </div>
1918 <img class="avatar" src="${ json [ index ] . picture } ">
20- </div>
21- ` ;
22- index = ( index + 1 ) % json . length ;
23- // });
19+ </div>` ;
20+ }
2421
2522 } ) ;
2623 } ) ;
You can’t perform that action at this time.
0 commit comments