Skip to content

Commit 6ed4674

Browse files
Blake SchwartzBlake Schwartz
authored andcommitted
D 7 finished
1 parent b8ff658 commit 6ed4674

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,47 @@
2525

2626
// Some and Every Checks
2727
// Array.prototype.some() // is at least one person 19?
28+
// const isAdult = people.some(function(person) {
29+
// const currentYear = (new Date()).getFullYear();
30+
// if (currentYear - person.year >= 19) {
31+
// return true;
32+
// }
33+
// });
34+
35+
const isAdult = people.some(person => ((new Date())
36+
.getFullYear()) - person.year >= 19);
37+
38+
console.log({isAdult});
2839
// Array.prototype.every() // is everyone 19?
2940

41+
const allAdults = people.every(person => ((new Date())
42+
.getFullYear()) - person.year >= 19);
43+
44+
console.log({allAdults});
3045
// Array.prototype.find()
3146
// Find is like filter, but instead returns just the one you are looking for
3247
// find the comment with the ID of 823423
3348

49+
const comment = comments.find(comment =>
50+
comment.id === 823423);
51+
52+
console.log(comment);
3453
// Array.prototype.findIndex()
3554
// Find the comment with this ID
3655
// delete the comment with the ID of 823423
3756

57+
const index = comments.findIndex(comment =>
58+
comment.id === 823423);
59+
60+
console.log({index});
61+
62+
// comments.splice(index, 1);
63+
64+
const newComments = [
65+
...comments.slice(0, index),
66+
...comments.slice(index + 1)
67+
];
68+
3869
</script>
3970
</body>
4071
</html>

0 commit comments

Comments
 (0)