Skip to content

Commit 8a7f054

Browse files
author
Jess Hines
committed
JDH: Finish 07 - Array Cardio 2
1 parent c98237d commit 8a7f054

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

07 - Array Cardio Day 2/index-START.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Document</title>
5+
<title>ArrayCardio pt 2</title>
66
</head>
77
<body>
88
<script>
@@ -25,15 +25,28 @@
2525

2626
// Some and Every Checks
2727
// Array.prototype.some() // is at least one person 19?
28+
var year = new Date().getFullYear();
29+
const haveAdults = people.some(person => year-person.year >= 19);
30+
console.log('have adults? ', haveAdults);
31+
2832
// Array.prototype.every() // is everyone 19?
33+
const allAdults = people.every(person => year-person.year >= 19);
34+
console.log('all adults? ', allAdults);
2935

3036
// Array.prototype.find()
3137
// Find is like filter, but instead returns just the one you are looking for
3238
// find the comment with the ID of 823423
39+
const comment = comments.find(comment => comment.id === 823423);
40+
console.log("comment found:",comment);
3341

3442
// Array.prototype.findIndex()
3543
// Find the comment with this ID
3644
// delete the comment with the ID of 823423
45+
console.log('size before: ', comments.length);
46+
const idx = comments.findIndex(comment => comment.id === 823423);
47+
comments.splice(idx,1);
48+
console.log('size after: ', comments.length, comments);
49+
3750

3851
</script>
3952
</body>

0 commit comments

Comments
 (0)