Skip to content

Commit 3ac39ea

Browse files
committed
[solved] day 07
1 parent aedcd73 commit 3ac39ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,28 @@
2626

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19?
29+
const isAdult = people.some(person => (new Date()).getFullYear() - person.year >= 19)
30+
const allAdult = people.every(person => (new Date()).getFullYear() - person.year >= 19)
31+
32+
console.log({allAdult});
2933
// Array.prototype.every() // is everyone 19?
3034

3135
// Array.prototype.find()
3236
// Find is like filter, but instead returns just the one you are looking for
3337
// find the comment with the ID of 823423
3438

39+
const comment = comments.find(comment => comment.id === 823423)
40+
console.log(comment)
3541
// Array.prototype.findIndex()
3642
// Find the comment with this ID
3743
// delete the comment with the ID of 823423
44+
const index = comments.findIndex(comment => comment.id === 823423)
45+
console.log(index);
3846

47+
const newComments = [
48+
...comments.slice(0, index),
49+
...comments.slice(index + 1)
50+
]
3951
</script>
4052
</body>
4153
</html>

0 commit comments

Comments
 (0)