File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 22< html lang ="en ">
33< head >
44 < meta charset ="UTF-8 ">
5- < title > Document </ title >
5+ < title > ArrayCardio pt 2 </ title >
66</ head >
77< body >
88 < script >
2525
2626 // Some and Every Checks
2727 // Array.prototype.some() // is at least one person 19?
28+ var year = new Date ( ) . getFullYear ( ) ;
29+ const haveAdults = people . some ( person => year - person . year >= 19 ) ;
30+ console . log ( 'have adults? ' , haveAdults ) ;
31+
2832 // Array.prototype.every() // is everyone 19?
33+ const allAdults = people . every ( person => year - person . year >= 19 ) ;
34+ console . log ( 'all adults? ' , allAdults ) ;
2935
3036 // Array.prototype.find()
3137 // Find is like filter, but instead returns just the one you are looking for
3238 // find the comment with the ID of 823423
39+ const comment = comments . find ( comment => comment . id === 823423 ) ;
40+ console . log ( "comment found:" , comment ) ;
3341
3442 // Array.prototype.findIndex()
3543 // Find the comment with this ID
3644 // delete the comment with the ID of 823423
45+ console . log ( 'size before: ' , comments . length ) ;
46+ const idx = comments . findIndex ( comment => comment . id === 823423 ) ;
47+ comments . splice ( idx , 1 ) ;
48+ console . log ( 'size after: ' , comments . length , comments ) ;
49+
3750
3851 </ script >
3952</ body >
You can’t perform that action at this time.
0 commit comments