Skip to content

Commit 5f552ef

Browse files
committed
1 parent 0190a17 commit 5f552ef

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,33 @@
2626

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19 or older?
29+
const isAdult = people.some(person => {
30+
const currentYear = (new Date()).getFullYear();
31+
return (currentYear - person.year >= 19);
32+
});
33+
2934
// Array.prototype.every() // is everyone 19 or older?
35+
const allAdult = people.every(person => {
36+
const currentYear = (new Date()).getFullYear();
37+
return (currentYear - person.year >= 19);
38+
});
39+
3040

3141
// Array.prototype.find()
3242
// Find is like filter, but instead returns just the one you are looking for
3343
// find the comment with the ID of 823423
34-
44+
const ourComment = comments.find(comment => comment.id === 823423)
45+
3546
// Array.prototype.findIndex()
47+
//
48+
const index = comments.findIndex(comment => comment.id === 823423)
3649
// Find the comment with this ID
3750
// delete the comment with the ID of 823423
51+
const newComments = [
52+
...comments.slice(0, index),
53+
...comments.slice(index + 1)
54+
]
55+
console.table(newComments)
3856

3957
</script>
4058
</body>

0 commit comments

Comments
 (0)