File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments