Visitar URL original
array cardio 2 · wesbos/JavaScript30@7328896 · GitHub
Skip to content

Commit 7328896

Browse files
committed
array cardio 2
1 parent b022023 commit 7328896

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

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

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

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

3143
// Array.prototype.find()
3244
// Find is like filter, but instead returns just the one you are looking for
3345
// find the comment with the ID of 823423
3446

47+
// const comment = comment.find(function(comment) {
48+
// if(comment.id === 823423) {
49+
// return true;
50+
// }
51+
// });
52+
// console.log(comment);
53+
3554
// Array.prototype.findIndex()
3655
// Find the comment with this ID
3756
// delete the comment with the ID of 823423
3857

58+
const index = comments.findIndex(comment => comment.id === 823423);
59+
console.log(index);
60+
61+
comments.splice(index, 1)
62+
3963
</script>
4064
</body>
4165
</html>

0 commit comments

Comments
 (0)