Skip to content

Commit 657673b

Browse files
committed
07 finis
1 parent 382a4a1 commit 657673b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,25 @@
2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19?
2929
// Array.prototype.every() // is everyone 19?
30+
const over19 = (el) => (new Date().getFullYear() - el.year) >= 19;
31+
const isAtLeastOneNineteen = people.some(over19);
32+
const isEveryNineteen = people.every(over19);
3033

3134
// Array.prototype.find()
3235
// Find is like filter, but instead returns just the one you are looking for
3336
// find the comment with the ID of 823423
37+
const commentWithId = comments.find((el, idx, arr) => el.id === 823423);
3438

3539
// Array.prototype.findIndex()
3640
// Find the comment with this ID
3741
// delete the comment with the ID of 823423
42+
const idx = comments.findIndex((el, idx, arr) => el.id === 823423);
43+
// slice vs splice - former is not mutative
44+
const newComments = [
45+
...comments.slice(0, idx -1),
46+
...comments.slice(idx)
47+
];
48+
console.log(isAtLeastOneNineteen, isEveryNineteen, commentWithId, newComments);
3849

3950
</script>
4051
</body>

0 commit comments

Comments
 (0)