File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 26
26
27
27
// Some and Every Checks
28
28
// Array.prototype.some() // is at least one person 19 or older?
29
+ const isAdult = people . some ( person => ( ( new Date ( ) ) . getFullYear ( ) - person . year ) >= 19 ) ;
30
+ console . log ( { isAdult} ) ;
31
+
29
32
// Array.prototype.every() // is everyone 19 or older?
33
+ const allAdults = people . every ( person => ( ( new Date ( ) ) . getFullYear ( ) - person . year ) >= 19 ) ;
34
+ console . log ( { allAdults} ) ;
30
35
31
36
// Array.prototype.find()
32
37
// Find is like filter, but instead returns just the one you are looking for
33
38
// find the comment with the ID of 823423
39
+ const comment = comments . find ( comment => comment . id === 823423 ) ;
40
+ console . log ( comment ) ;
34
41
35
42
// Array.prototype.findIndex()
36
43
// Find the comment with this ID
37
44
// delete the comment with the ID of 823423
45
+ const index = comments . findIndex ( comment => comment . id == 823423 ) ;
46
+ comments . splice ( index , 1 ) ;
38
47
48
+ console . table ( comments ) ;
39
49
</ script >
40
50
</ body >
41
51
</ html >
You can’t perform that action at this time.
0 commit comments