Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed project #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-minimal
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width">
<title>Astronauts</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
Expand Down
40 changes: 39 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
// TODO: add code here
window.addEventListener('load',function(){
let astronauts = fetch("https://handlers.education.launchcode.org/static/astronauts.json");
astronauts.then(function(response){
let data = response.json();
data.then(function(data){
let results = document.querySelector('#container');
data.sort((a,b)=>b.hoursInSpace-a.hoursInSpace);
for(let a=0;a<data.length;a++){
results.innerHTML += `
<div class="astronaut">
<div class="bio">
<h3>${data[a].firstName} ${data[a].lastName}</h3>
<ul>
<li>Hours in space: ${data[a].hoursInSpace}</li>
<li id='color'>Active: ${data[a].active}</li>
<li>Skills: ${data[a].skills}</li>
</ul>
</div>
<img class="avatar" src="${data[a].picture}">
</div>
`;
}
let count = document.querySelector('h1');
count.innerHTML += ` ${data.length}`;
setColor();
});
});
});
function setColor(){
let elements = document.querySelectorAll('li');
for(let a=0;a<elements.length;a++){
if(elements[a].innerHTML === 'Active: true'){
elements[a].style.color = 'green';
}
}
}



3 changes: 3 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#color{
color: red;
}