Skip to content

Commit cb87ddb

Browse files
committed
Lesson 7 solutions.
1 parent 063c15e commit cb87ddb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

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

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19?
29+
const year = new Date().getFullYear();
30+
const year19 = year - 19;
31+
console.log('At least one person 19: ' + people.some(person => person.year < year19));
32+
2933
// Array.prototype.every() // is everyone 19?
34+
console.log('Every person 19: ' + people.every(person => person.year < year19));
3035

3136
// Array.prototype.find()
3237
// Find is like filter, but instead returns just the one you are looking for
3338
// find the comment with the ID of 823423
39+
var commentText = comments.filter(comment => comment.id === 823423);
40+
console.table(commentText);
3441

3542
// Array.prototype.findIndex()
3643
// Find the comment with this ID
44+
var commentTextIndex = comments.findIndex(comment => comment.id === 823423);
3745
// delete the comment with the ID of 823423
46+
var newComments = [
47+
...comments.slice(0, commentTextIndex),
48+
...comments.slice(commentTextIndex + 1)
49+
]
50+
console.table(newComments);
3851

3952
</script>
4053
</body>

0 commit comments

Comments
 (0)