File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 // if(currentYear - person.year >= 19) {
3131 // return true;
3232 // }
33- // });
33+ // });console.log({isAdult});
3434
35- const isAdult = people . some ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
36-
37- console . log ( { isAdult} ) ;
3835 // Array.prototype.every() // is everyone 19?
3936
40- const allAdults = people . every ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
41- console . log ( { allAdults} ) ;
42-
4337 // Array.prototype.find()
4438 // Find is like filter, but instead returns just the one you are looking for
4539 // find the comment with the ID of 823423
4640
47-
48- const comment = comments . find ( comment => comment . id === 823423 ) ;
49-
50- console . log ( comment ) ;
51-
5241 // Array.prototype.findIndex()
5342 // Find the comment with this ID
5443 // delete the comment with the ID of 823423
55- const index = comments . findIndex ( comment => comment . id === 823423 ) ;
56- console . log ( index ) ;
57-
58- // comments.splice(index, 1);
5944
60- const newComments = [
61- ...comments . slice ( 0 , index ) ,
62- ...comments . slice ( index + 1 )
63- ] ;
6445
6546 </ script >
6647</ body >
You can’t perform that action at this time.
0 commit comments