Skip to content

Commit 500cc0d

Browse files
committed
Array Cardio wesbos#2
1 parent da0a874 commit 500cc0d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,40 @@
2929
// Array.prototype.some() // is at least one person 19 or older?
3030
// Array.prototype.every() // is everyone 19 or older?
3131

32+
const aboveNineteen = people.some(person=> {
33+
const currentYear = (new Date()).getFullYear();
34+
return currentYear - person.year >= 19;
35+
})
36+
37+
console.log({aboveNineteen});
38+
39+
const aboveNineteens = people.every(person=> {
40+
const currentYear = (new Date()).getFullYear();
41+
return currentYear - person.year >= 19;
42+
})
43+
44+
console.log({aboveNineteens});
45+
3246
// Array.prototype.find()
3347
// Find is like filter, but instead returns just the one you are looking for
3448
// find the comment with the ID of 823423
3549

50+
const commentFind = comments.find (comment=>comment.id===823423)
51+
console.log(commentFind);
52+
53+
54+
3655
// Array.prototype.findIndex()
3756
// Find the comment with this ID
3857
// delete the comment with the ID of 823423
3958

59+
const deleteComment = comments.findIndex (comment=>comment.id===823423)
60+
console.log(deleteComment);
61+
62+
comments.splice(deleteComment,1);
63+
64+
65+
4066
</script>
4167
</body>
4268
</html>

0 commit comments

Comments
 (0)