Skip to content

Commit 738ea39

Browse files
committed
exercise wesbos#7
1 parent 1a95995 commit 738ea39

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,29 @@
2626

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19 or older?
29+
const isAdult = people.some(person => {
30+
const currentYear = new Date();
31+
return currentYear.getFullYear() - person.year >= 19;
32+
});
33+
console.log({isAdult});
2934
// Array.prototype.every() // is everyone 19 or older?
30-
35+
const allAdults = people.every(person => {
36+
const currentYear = new Date();
37+
return currentYear.getFullYear() - person.year >= 19;
38+
});
39+
console.log({allAdults});
3140
// Array.prototype.find()
3241
// Find is like filter, but instead returns just the one you are looking for
3342
// find the comment with the ID of 823423
43+
const comment = comments.find(comment => comment.id === 823423);
44+
console.log({comment});
3445

3546
// Array.prototype.findIndex()
3647
// Find the comment with this ID
48+
const index = comments.findIndex(comment => comment.id === 823423);
49+
console.log({index});
50+
comments.splice(index, 1);
51+
console.log({comments});
3752
// delete the comment with the ID of 823423
3853

3954
</script>

0 commit comments

Comments
 (0)