Skip to content

Commit 64c019e

Browse files
committed
Complete 07
1 parent 045318d commit 64c019e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,38 @@
2727

2828
// Some and Every Checks
2929
// Array.prototype.some() // is at least one person 19 or older?
30+
// const isAdult = people.some((person) => {
31+
// const currentYear = new Date().getFullYear();
32+
// if (currentYear - person.year >= 19) {
33+
// return true;
34+
// }
35+
// });
36+
37+
const isAdult = people.some((person) => (new Date().getFullYear() - person.year) >= 19);
38+
console.log({isAdult});
3039
// Array.prototype.every() // is everyone 19 or older?
40+
const allAdults = people.every((person) =>( new Date().getFullYear() - person.year) >= 19);
41+
console.log({allAdults});
3142

3243
// Array.prototype.find()
3344
// Find is like filter, but instead returns just the one you are looking for
3445
// find the comment with the ID of 823423
46+
const comment = comments.find((comment) => comment.id === 823423);
47+
console.log(comment);
3548

3649
// Array.prototype.findIndex()
3750
// Find the comment with this ID
3851
// delete the comment with the ID of 823423
52+
const index = comments.findIndex((index) => index.id === 823423);
53+
console.log(index);
54+
// comments.splice(index, 1);
55+
// console.log(comments);
56+
57+
const newComments = [
58+
...comments.slice(0, index),
59+
...comments.slice(index + 1)
60+
];
61+
console.log(newComments);
3962

4063
</script>
4164
</body>

0 commit comments

Comments
 (0)