File tree Expand file tree Collapse file tree 1 file changed +0
-27
lines changed Expand file tree Collapse file tree 1 file changed +0
-27
lines changed Original file line number Diff line number Diff line change 2525
2626 // Some and Every Checks
2727 // Array.prototype.some() // is at least one person 19?
28- // const isAdult = people.some(function(person) {
29- // const currentYear = (new Date()).getFullYear();
30- // if(currentYear - person.year >= 19) {
31- // return true;
32- // }
33- // });
34-
35- const isAdult = people . some ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
36-
37- console . log ( { isAdult} ) ;
3828 // Array.prototype.every() // is everyone 19?
3929
40- const allAdults = people . every ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
41- console . log ( { allAdults} ) ;
42-
4330 // Array.prototype.find()
4431 // Find is like filter, but instead returns just the one you are looking for
4532 // find the comment with the ID of 823423
4633
47-
48- const comment = comments . find ( comment => comment . id === 823423 ) ;
49-
50- console . log ( comment ) ;
51-
5234 // Array.prototype.findIndex()
5335 // Find the comment with this ID
5436 // 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);
59-
60- const newComments = [
61- ...comments . slice ( 0 , index ) ,
62- ...comments . slice ( index + 1 )
63- ] ;
6437
6538 </ script >
6639</ body >
You can’t perform that action at this time.
0 commit comments