File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-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 year = new Date ( ) . getFullYear ( ) ;
30+ const year19 = year - 19 ;
31+ console . log ( 'At least one person 19: ' + people . some ( person => person . year < year19 ) ) ;
32+
2933 // Array.prototype.every() // is everyone 19?
34+ console . log ( 'Every person 19: ' + people . every ( person => person . year < year19 ) ) ;
3035
3136 // Array.prototype.find()
3237 // Find is like filter, but instead returns just the one you are looking for
3338 // find the comment with the ID of 823423
39+ var commentText = comments . filter ( comment => comment . id === 823423 ) ;
40+ console . table ( commentText ) ;
3441
3542 // Array.prototype.findIndex()
3643 // Find the comment with this ID
44+ var commentTextIndex = comments . findIndex ( comment => comment . id === 823423 ) ;
3745 // delete the comment with the ID of 823423
46+ var newComments = [
47+ ...comments . slice ( 0 , commentTextIndex ) ,
48+ ...comments . slice ( commentTextIndex + 1 )
49+ ]
50+ console . table ( newComments ) ;
3851
3952 </ script >
4053</ body >
You can’t perform that action at this time.
0 commit comments