Visitar URL original
JS30 #7 completed · bhaveshgoyal182/JavaScript30@1d15162 · GitHub
Skip to content

Commit 1d15162

Browse files
author
=
committed
JS30 wesbos#7 completed
1 parent a02fbb4 commit 1d15162

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 20 additions & 1 deletion
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 => ((new Date).getFullYear()) - person.year >= 19);
30+
console.log(isAdult);
2931
// Array.prototype.every() // is everyone 19 or older?
30-
32+
const allAdults = people.every(person => ((new Date).getFullYear()) - person.year >= 19);
33+
console.log(allAdults);
3134
// Array.prototype.find()
3235
// Find is like filter, but instead returns just the one you are looking for
3336
// find the comment with the ID of 823423
37+
const comment = comments.find(comment => comment.id === 823423);
38+
console.log(comment);
3439

3540
// Array.prototype.findIndex()
3641
// Find the comment with this ID
42+
const commentIndex = comments.findIndex(comment => comment.id === 823423);
43+
console.log(commentIndex);
44+
console.table(comments);
3745
// delete the comment with the ID of 823423
46+
//2 methods available for this
47+
// 1st method to splice the array
48+
comments.splice(commentIndex,2);
49+
console.table(comments);
50+
51+
// 2nd method to make a new array and copy the other objects in that array
52+
// const newArray = [
53+
// ...comments.slice(0,commentIndex),
54+
// ...comments.slice(commentIndex + 1)
55+
// ];
56+
// console.log(newArray);
3857

3958
</script>
4059
</body>

0 commit comments

Comments
 (0)