File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed 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?
29+ const isAdult = people . some ( person => ( new Date ( ) ) . getFullYear ( ) - person . year >= 19 )
30+ const allAdult = people . every ( person => ( new Date ( ) ) . getFullYear ( ) - person . year >= 19 )
31+
32+ console . log ( { allAdult} ) ;
2933 // Array.prototype.every() // is everyone 19?
3034
3135 // Array.prototype.find()
3236 // Find is like filter, but instead returns just the one you are looking for
3337 // find the comment with the ID of 823423
3438
39+ const comment = comments . find ( comment => comment . id === 823423 )
40+ console . log ( comment )
3541 // Array.prototype.findIndex()
3642 // Find the comment with this ID
3743 // delete the comment with the ID of 823423
44+ const index = comments . findIndex ( comment => comment . id === 823423 )
45+ console . log ( index ) ;
3846
47+ const newComments = [
48+ ...comments . slice ( 0 , index ) ,
49+ ...comments . slice ( index + 1 )
50+ ]
3951 </ script >
4052</ body >
4153</ html >
You can’t perform that action at this time.
0 commit comments