File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
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 ( ( people ) => {
30+ return ( new Date ( ) . getFullYear ( ) ) - people . year >= 19 ;
31+ } ) ;
32+ console . log ( isAdult ) ;
2933 // Array.prototype.every() // is everyone 19?
34+ const allAdult = people . every ( ( people ) => {
35+ return ( new Date ( ) . getFullYear ( ) ) - people . year >= 19 ;
36+ } ) ;
37+ console . log ( allAdult ) ;
3038
3139 // Array.prototype.find()
3240 // Find is like filter, but instead returns just the one you are looking for
3341 // find the comment with the ID of 823423
42+ const didWeGetIt = comments . find ( function ( item ) {
43+
44+ if ( item . id === 823423 ) {
45+ return item . text ;
46+ }
47+ } ) ;
3448
35- // Array.prototype.findIndex()
49+ console . log ( didWeGetIt ) ;
50+
51+ // Array.prototype.findIndex()
3652 // Find the comment with this ID
3753 // delete the comment with the ID of 823423
54+ const index = comments . findIndex ( comment => comment . id === 823423 ) ;
55+
56+ console . log ( index ) ;
57+ comments . splice ( index , 1 ) ;
58+ console . table ( comments ) ;
59+
3860
3961 </ script >
4062</ body >
You can’t perform that action at this time.
0 commit comments