File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 2424 { text : 'Nice Nice Nice!' , id : 542328 }
2525 ] ;
2626
27+ // const ofAge = people.some(function(person) {
28+ // const currYear = (new Date()).getFullYear();
29+ // if(currYear - person.year >= 19) {
30+ // return true;
31+ // }
32+ // })
33+ // console.log(ofAge)
34+
35+ const ofAge = people . every ( function ( person ) {
36+ const currYear = ( new Date ( ) ) . getFullYear ( ) ;
37+ return currYear - person . year >= 19
38+ } )
39+
40+ console . log ( ofAge )
2741 // Some and Every Checks
2842 // Array.prototype.some() // is at least one person 19?
2943 // Array.prototype.every() // is everyone 19?
3246 // Find is like filter, but instead returns just the one you are looking for
3347 // find the comment with the ID of 823423
3448
49+ const found = comments . find ( function ( message ) {
50+ return message . id === 823423
51+ } )
52+
53+ console . log ( found )
54+
55+ const foundIndex = comments . findIndex ( function ( message ) {
56+ return message . id === 823423
57+
58+ } )
59+
60+ comments . splice ( foundIndex , 1 )
61+ console . log ( comments )
62+
3563 // Array.prototype.findIndex()
3664 // Find the comment with this ID
3765 // delete the comment with the ID of 823423
You can’t perform that action at this time.
0 commit comments