Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c96fd7b

Browse files
committed
7th exercise done
1 parent 0d2f6ee commit c96fd7b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

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

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19?
29+
const currentYear = (new Date()).getFullYear();
30+
const someAreNineteen = people.some(person => currentYear - person.year >= 19);
31+
console.log('Someone is 19', someAreNineteen);
2932
// Array.prototype.every() // is everyone 19?
33+
const allAreNineteen = people.every(person => currentYear - person.year >= 19);
34+
console.log('All are 19', allAreNineteen);
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+
const theFoundComment = comments.find(comment => comment.id === 823423);
40+
console.log('The found comment:', theFoundComment);
3441

3542
// Array.prototype.findIndex()
3643
// Find the comment with this ID
3744
// delete the comment with the ID of 823423
45+
const theIndex = comments.findIndex(comment => comment.id === 823423);
46+
console.log('Comments before');
47+
console.table(comments);
48+
const newComments = [
49+
...comments.slice(0, theIndex),
50+
...comments.slice(theIndex + 1)
51+
];
52+
console.log('Comments after');
53+
console.table(newComments);
3854

3955
</script>
4056
</body>

0 commit comments

Comments
 (0)