Skip to content

Commit 3c4ae43

Browse files
author
nrvarun
committed
Day 7 completed
1 parent f6c7cfa commit 3c4ae43

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,37 @@
2626

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

3139
// Array.prototype.find()
3240
// Find is like filter, but instead returns just the one you are looking for
3341
// find the comment with the ID of 823423
42+
const didWeGetIt = comments.find(function(item) {
43+
44+
if (item.id === 823423) {
45+
return item.text;
46+
}
47+
});
3448

35-
// Array.prototype.findIndex()
49+
console.log(didWeGetIt);
50+
51+
// Array.prototype.findIndex()
3652
// Find the comment with this ID
3753
// delete the comment with the ID of 823423
54+
const index = comments.findIndex(comment => comment.id === 823423);
55+
56+
console.log(index);
57+
comments.splice(index, 1);
58+
console.table(comments);
59+
3860

3961
</script>
4062
</body>

0 commit comments

Comments
 (0)