Skip to content

Commit 4700e86

Browse files
committed
Day 7 Array Cardio Day 2
1 parent 79368ce commit 4700e86

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,45 @@
2424
{ text: 'Nice Nice Nice!', id: 542328 }
2525
];
2626

27+
console.log("ready?")
28+
2729
// Some and Every Checks
28-
// Array.prototype.some() // is at least one person 19 or older?
30+
// Array.prototype.some() // is at least one person 19?
31+
// const isAdult = people.some(function(person){
32+
// const currentYear = (new Date()).getFullYear();
33+
// if(currentYear - person.year >= 19){
34+
// return true;
35+
// }
36+
// });
37+
38+
const isAdult = people.some(person => ((new Date()).
39+
getFullYear()) - person.year >= 19);
40+
41+
console.log({isAdult});
42+
2943
// Array.prototype.every() // is everyone 19 or older?
44+
const allAdults = people.every(person => ((new Date()).
45+
getFullYear()) - person.year >= 19);
46+
47+
console.log({allAdults});
3048

3149
// Array.prototype.find()
3250
// Find is like filter, but instead returns just the one you are looking for
3351
// find the comment with the ID of 823423
52+
const comment = comments.find(comment => comment.id === 823423);
53+
console.log(comment);
3454

3555
// Array.prototype.findIndex()
3656
// Find the comment with this ID
3757
// delete the comment with the ID of 823423
58+
const index = comments.findIndex(comment => comment.id === 823423);
59+
console.log(index);
60+
61+
//comments.splice(index, 1);
62+
const newComments = [
63+
...comments.slice(0, index),
64+
...comments.slice(index + 1)
65+
];
3866

3967
</script>
4068
</body>

0 commit comments

Comments
 (0)