Skip to content

Commit 44f1bf5

Browse files
author
Yuri Brunetto
committed
complete wesbos#7
1 parent 2b071c6 commit 44f1bf5

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,36 @@
2525

2626
// Some and Every Checks
2727
// Array.prototype.some() // is at least one person 19?
28-
// const isAdult = people.some(function(person) {
29-
// const currentYear = (new Date()).getFullYear();
30-
// if(currentYear - person.year >= 19) {
31-
// return true;
32-
// }
33-
// });
28+
const isAdult = people.some(person => {
29+
const currentYear = (new Date()).getFullYear()
30+
return currentYear - person.year >= 19
31+
})
32+
console.log({isAdult})
3433

35-
const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19);
36-
37-
console.log({isAdult});
3834
// Array.prototype.every() // is everyone 19?
39-
40-
const allAdults = people.every(person => ((new Date()).getFullYear()) - person.year >= 19);
41-
console.log({allAdults});
35+
const allAdults = people.every(person => {
36+
const currentYear = (new Date()).getFullYear()
37+
return currentYear - person.year >= 19
38+
})
39+
console.log({allAdults})
4240

4341
// Array.prototype.find()
4442
// Find is like filter, but instead returns just the one you are looking for
4543
// find the comment with the ID of 823423
46-
47-
48-
const comment = comments.find(comment => comment.id === 823423);
49-
50-
console.log(comment);
44+
const comment = comments.find(comment => comment.id === 823423)
45+
console.log(comment)
5146

5247
// Array.prototype.findIndex()
5348
// Find the comment with this ID
5449
// delete the comment with the ID of 823423
55-
const index = comments.findIndex(comment => comment.id === 823423);
56-
console.log(index);
57-
58-
// comments.splice(index, 1);
50+
const index = comments.findIndex(comment => comment.id === 823423)
51+
console.log(index)
5952

53+
// comments.splice(index, 1)
6054
const newComments = [
6155
...comments.slice(0, index),
6256
...comments.slice(index + 1)
63-
];
57+
]
6458

6559
</script>
6660
</body>

0 commit comments

Comments
 (0)