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 => {
30+ const currentYear = new Date ( ) ;
31+ return currentYear . getFullYear ( ) - person . year >= 19 ;
32+ } ) ;
33+ console . log ( { isAdult} ) ;
2934 // Array.prototype.every() // is everyone 19 or older?
30-
35+ const allAdults = people . every ( person => {
36+ const currentYear = new Date ( ) ;
37+ return currentYear . getFullYear ( ) - person . year >= 19 ;
38+ } ) ;
39+ console . log ( { allAdults} ) ;
3140 // Array.prototype.find()
3241 // Find is like filter, but instead returns just the one you are looking for
3342 // find the comment with the ID of 823423
43+ const comment = comments . find ( comment => comment . id === 823423 ) ;
44+ console . log ( { comment} ) ;
3445
3546 // Array.prototype.findIndex()
3647 // Find the comment with this ID
48+ const index = comments . findIndex ( comment => comment . id === 823423 ) ;
49+ console . log ( { index} ) ;
50+ comments . splice ( index , 1 ) ;
51+ console . log ( { comments} ) ;
3752 // delete the comment with the ID of 823423
3853
3954 </ script >
You can’t perform that action at this time.
0 commit comments