Skip to content

Commit bb4175b

Browse files
Charlene TranCharlene Tran
Charlene Tran
authored and
Charlene Tran
committed
CT completed - working on Bonus LaunchCodeEducation#1, completed LaunchCodeEducation#2-3
1 parent 2977984 commit bb4175b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

fetch/studio-CT/script.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,29 @@ window.addEventListener("load", function () {
1414
const container = document.getElementById("container");
1515

1616
// Using a For Loop to iterated through each object in the array in json
17+
let activeAstronauts = 0
18+
1719
for (let i = 0; i < json.length; i++) {
18-
container.innerHTML += `
20+
21+
if (json[i].active) {
22+
activeAstronauts += 1;
23+
container.innerHTML += `
24+
<div class="astronaut">
25+
<div class="bio">
26+
<h3>${json[i].firstName} ${json[i].lastName}</h3>
27+
<ul>
28+
<li>Hours in space: ${json[i].hoursInSpace}</li>
29+
<li class="active">Active: ${json[i].active}</li>
30+
<li>Skills: ${json[i].skills}</li>
31+
</ul>
32+
</div>
33+
<img class="avatar" src="${json[i].picture}">
34+
</div>
35+
36+
37+
`
38+
} else {
39+
container.innerHTML += `
1940
<div class="astronaut">
2041
<div class="bio">
2142
<h3>${json[i].firstName} ${json[i].lastName}</h3>
@@ -27,8 +48,17 @@ window.addEventListener("load", function () {
2748
</div>
2849
<img class="avatar" src="${json[i].picture}">
2950
</div>
51+
3052
`
53+
}
3154
}
55+
56+
container.innerHTML += `
57+
<p>
58+
Total Number of Astronauts: ${json.length} <br>
59+
<span class="active">Total ACTIVE Astronauts: ${activeAstronauts}</span>
60+
</p>
61+
`
3262
});
3363
});
3464
});

fetch/studio-CT/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
margin-bottom: 20px;
1515
border-radius: 6px;
1616
}
17+
18+
.active {
19+
color: green;
20+
}

0 commit comments

Comments
 (0)