File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
2931 // Array.prototype.every() // is everyone 19 or older?
32+ const allAdult = people . every ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
3033
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 ) ;
3438
3539 // Array.prototype.findIndex()
3640 // Find the comment with this ID
3741 // delete the comment with the ID of 823423
3842
43+ const index = comments . findIndex ( comment => comment . id === 823423 ) ;
44+
45+ const newComments = [
46+ ...comments . slice ( 0 , index ) ,
47+ ...comments . slice ( index + 1 )
48+ ] ;
49+
3950 </ script >
4051</ body >
4152</ html >
You can’t perform that action at this time.
0 commit comments