File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 2929 // Array.prototype.some() // is at least one person 19 or older?
3030 // Array.prototype.every() // is everyone 19 or older?
3131
32+ const aboveNineteen = people . some ( person => {
33+ const currentYear = ( new Date ( ) ) . getFullYear ( ) ;
34+ return currentYear - person . year >= 19 ;
35+ } )
36+
37+ console . log ( { aboveNineteen} ) ;
38+
39+ const aboveNineteens = people . every ( person => {
40+ const currentYear = ( new Date ( ) ) . getFullYear ( ) ;
41+ return currentYear - person . year >= 19 ;
42+ } )
43+
44+ console . log ( { aboveNineteens} ) ;
45+
3246 // Array.prototype.find()
3347 // Find is like filter, but instead returns just the one you are looking for
3448 // find the comment with the ID of 823423
3549
50+ const commentFind = comments . find ( comment => comment . id === 823423 )
51+ console . log ( commentFind ) ;
52+
53+
54+
3655 // Array.prototype.findIndex()
3756 // Find the comment with this ID
3857 // delete the comment with the ID of 823423
3958
59+ const deleteComment = comments . findIndex ( comment => comment . id === 823423 )
60+ console . log ( deleteComment ) ;
61+
62+ comments . splice ( deleteComment , 1 ) ;
63+
64+
65+
4066 </ script >
4167</ body >
4268</ html >
You can’t perform that action at this time.
0 commit comments