Skip to content

Commit 94c764a

Browse files
committed
feat: add challenge wesbos#7
1 parent 5d3a957 commit 94c764a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

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

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19 or older?
29+
const isAdult = people.some((person) => {
30+
const currentYear = (new Date()).getFullYear();
31+
return currentYear - person.year >= 19
32+
});
33+
console.log('At least one perso is 19 or older: ' + isAdult);
34+
2935
// Array.prototype.every() // is everyone 19 or older?
36+
const areAllAdults = people.every((person) => {
37+
const currentYear = (new Date()).getFullYear();
38+
return currentYear - person.year >= 19
39+
})
40+
console.log('Is everyone an adult: ' + areAllAdults);
3041

3142
// Array.prototype.find()
3243
// Find is like filter, but instead returns just the one you are looking for
3344
// find the comment with the ID of 823423
45+
const comment = comments.find(comment => comment.id === 823423);
46+
console.log(comment);
3447

3548
// Array.prototype.findIndex()
3649
// Find the comment with this ID
3750
// delete the comment with the ID of 823423
51+
const index = comments.findIndex(comment => comment.id === 823423);
52+
const newComments = [
53+
...comments.slice(0, index),
54+
...comments.slice(index + 1)
55+
]
56+
console.table(newComments);
3857

3958
</script>
4059
</body>

0 commit comments

Comments
 (0)