File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-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 or older?
29+ const isAdult = people . some ( person => {
30+ const currentYear = ( new Date ( ) ) . getFullYear ( ) ;
31+ return ( currentYear - person . year >= 19 ) ;
32+ } ) ;
33+
2934 // Array.prototype.every() // is everyone 19 or older?
35+ const allAdult = people . every ( person => {
36+ const currentYear = ( new Date ( ) ) . getFullYear ( ) ;
37+ return ( currentYear - person . year >= 19 ) ;
38+ } ) ;
39+
3040
3141 // Array.prototype.find()
3242 // Find is like filter, but instead returns just the one you are looking for
3343 // find the comment with the ID of 823423
34-
44+ const ourComment = comments . find ( comment => comment . id === 823423 )
45+
3546 // Array.prototype.findIndex()
47+ //
48+ const index = comments . findIndex ( comment => comment . id === 823423 )
3649 // Find the comment with this ID
3750 // delete the comment with the ID of 823423
51+ const newComments = [
52+ ...comments . slice ( 0 , index ) ,
53+ ...comments . slice ( index + 1 )
54+ ]
55+ console . table ( newComments )
3856
3957 </ script >
4058</ body >
You can’t perform that action at this time.
0 commit comments