Skip to content

Commit ea859f5

Browse files
committed
Completed JavaScript30 wesbos#7
1 parent 6258422 commit ea859f5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

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

32+
const isAdult = people.some(person => {
33+
const currentYear = (new Date().getFullYear());
34+
if(currentYear - person.year >= 19) {
35+
return true;
36+
}
37+
})
38+
console.log({isAdult})
39+
40+
const allAdult = people.every(person => {
41+
const currentYear = (new Date().getFullYear());
42+
if(currentYear - person.year >= 19) {
43+
return true;
44+
}
45+
})
46+
console.log({allAdult})
47+
3248
// Array.prototype.find()
3349
// Find is like filter, but instead returns just the one you are looking for
3450
// find the comment with the ID of 823423
3551

52+
const found = comments.find(element => element.id === 823423)
53+
console.log(found)
54+
55+
56+
3657
// Array.prototype.findIndex()
3758
// Find the comment with this ID
3859
// delete the comment with the ID of 823423
60+
const index = comments.findIndex(comment => comment.id === 823423);
61+
console.log(found)
62+
comments.splice(index, 1);
63+
console.log(comments)
3964

4065
</script>
4166
</body>

0 commit comments

Comments
 (0)