Skip to content

Commit 8364124

Browse files
committed
Add cindy day 7
1 parent a754082 commit 8364124

File tree

5 files changed

+68
-2
lines changed

5 files changed

+68
-2
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ <h5 class="font-weight-bold font-italic text-white team-tag">TEAM</h5>
455455
<li>Day#03|<span>CSS Variables</span>
456456
</li>
457457
</a>
458-
<a class="project-item" href="team/Cindy/Day4 - Array Cardio/index.html">
458+
<a class="project-item" href="team/Cindy/Day4 - Array Cardio Day 1/index.html">
459459
<li>Day#04|<span>Array Cardio Day 1</span>
460460
</li>
461461
</a>
@@ -467,7 +467,7 @@ <h5 class="font-weight-bold font-italic text-white team-tag">TEAM</h5>
467467
<li>Day#06|<span>Type Ahead</span>
468468
</li>
469469
</a>
470-
<a class="project-item" href="#">
470+
<a class="project-item" href="team/Cindy/Day7 - Array Cardio Day 2/index.html">
471471
<li>Day#07|<span>Array Cardio Day 2</span>
472472
</li>
473473
</a>
File renamed without changes.
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Array Cardio 💪💪</title>
6+
</head>
7+
<body>
8+
<p><em>Psst: have a look at the JavaScript Console</em> 🐤</p>
9+
<ul>
10+
<li><b>Q1</b> is at least one person 19 or older?</li>
11+
<li class="answer1"></li>
12+
<li><b>Q2</b> is at least one person 19 or older?</li>
13+
<li class="answer2"></li>
14+
<li><b>Q3</b> find the comment with the ID of 823423</li>
15+
<li class="answer3"></li>
16+
<li><b>Q4</b> delete the comment with the ID of 823423</li>
17+
<li class="answer4"></li>
18+
</ul>
19+
<script src="./main.js"></script>
20+
</body>
21+
</html>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const answer1 = document.querySelector('.answer1');
2+
const answer2 = document.querySelector('.answer2');
3+
const answer3 = document.querySelector('.answer3');
4+
const answer4 = document.querySelector('.answer4');
5+
6+
const people = [
7+
{ name: 'Wes', year: 1988 },
8+
{ name: 'Kait', year: 1986 },
9+
{ name: 'Irv', year: 1970 },
10+
{ name: 'Lux', year: 2015 }
11+
];
12+
13+
const comments = [
14+
{ text: 'Love this!', id: 523423 },
15+
{ text: 'Super good', id: 823423 },
16+
{ text: 'You are the best', id: 2039842 },
17+
{ text: 'Ramen is my fav food ever', id: 123523 },
18+
{ text: 'Nice Nice Nice!', id: 542328 }
19+
];
20+
21+
// Some and Every Checks
22+
// Array.prototype.some() // is at least one person 19 or older?
23+
// Array.prototype.every() // is everyone 19 or older?
24+
const isAudlt = people.some(person => (new Date()).getFullYear() - person.year >= 19);
25+
console.log(`is at least one person 19 or older? ${isAudlt}`);
26+
answer1.innerHTML = isAudlt;
27+
const allAdult = people.every(person => (new Date()).getFullYear() - person.year >= 19);
28+
console.log(`is everyone 19 or older? ${allAdult}`);
29+
answer2.innerHTML = allAdult;
30+
31+
// Array.prototype.find()
32+
// Find is like filter, but instead returns just the one you are looking for
33+
// find the comment with the ID of 823423
34+
const findComment = comments.find(comment => comment.id === 823423);
35+
console.log(findComment);
36+
answer3.innerHTML = `text: ${findComment.text}, id: ${findComment.id}`;
37+
38+
// Array.prototype.findIndex()
39+
// Find the comment with this ID
40+
// delete the comment with the ID of 823423
41+
const findCommentIndex = comments.findIndex(comment => comment.id === 823423);
42+
console.log(`findCommentIndex: ${findCommentIndex}`);
43+
comments.splice(findCommentIndex, 1);
44+
console.log(comments);
45+
answer4.innerHTML = JSON.stringify(comments)

0 commit comments

Comments
 (0)