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

Skip to content

Commit cf3d53f

Browse files
committed
Complete Day wesbos#7 Challenge | Array Cardio Day 2
1 parent d3ba955 commit cf3d53f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,34 @@
2727

2828
// Some and Every Checks
2929
// Array.prototype.some() // is at least one person 19 or older?
30+
// const isAdult = people.some(function(person) {
31+
// const currentYear = (new Date()).getFullYear();
32+
// if (currentYear - person.year){
33+
// return true;
34+
// }
35+
// });
36+
37+
const isAdult = people.some(person => (new Date()).getFullYear() - person.year >= 19);
38+
console.log(isAdult);
3039
// Array.prototype.every() // is everyone 19 or older?
40+
const allAdults = people.every(person => (new Date()).getFullYear() - person.year >= 19);
41+
console.log(allAdults);
3142

3243
// Array.prototype.find()
3344
// Find is like filter, but instead returns just the one you are looking for
3445
// find the comment with the ID of 823423
3546

47+
const comment = comments.find(comment => comment.id === 823423);
48+
console.log(comment);
49+
3650
// Array.prototype.findIndex()
3751
// Find the comment with this ID
3852
// delete the comment with the ID of 823423
3953

54+
const index = comments.findIndex(comment => comment.id === 823423);
55+
comments.splice(index, 1);
56+
console.log(comments);
57+
4058
</script>
4159
</body>
4260
</html>

0 commit comments

Comments
 (0)