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