Skip to content

Commit 9f731af

Browse files
committed
code along to wesbos#7 array methods part 2
1 parent efcdebd commit 9f731af

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
@@ -26,16 +26,27 @@
2626

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19 or older?
29+
const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19);
30+
2931
// Array.prototype.every() // is everyone 19 or older?
32+
const allAdult = people.every(person => ((new Date()).getFullYear()) - person.year >= 19);
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 comment = comments.find(comment => comment.id === 823423);
3438

3539
// Array.prototype.findIndex()
3640
// Find the comment with this ID
3741
// delete the comment with the ID of 823423
3842

43+
const index = comments.findIndex(comment => comment.id === 823423);
44+
45+
const newComments = [
46+
...comments.slice(0, index),
47+
...comments.slice(index + 1)
48+
];
49+
3950
</script>
4051
</body>
4152
</html>

0 commit comments

Comments
 (0)