11<!DOCTYPE html>
22< html lang ="en ">
3+
34< head >
45 < meta charset ="UTF-8 ">
56 < title > Document</ title >
67</ head >
8+
79< body >
810 < script >
911 // ## Array Cardio Day 2
2426 ] ;
2527
2628 // Some and Every Checks
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-
29+ // Array.prototype.some()
30+ // is at least one person 19?
3531 const isAdult = people . some ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
32+ console . log ( { isAdult } ) ;
3633
37- console . log ( { isAdult} ) ;
3834 // Array.prototype.every() // is everyone 19?
39-
4035 const allAdults = people . every ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
41- console . log ( { allAdults} ) ;
36+ console . log ( { allAdults } ) ;
4237
4338 // Array.prototype.find()
4439 // Find is like filter, but instead returns just the one you are looking for
4540 // find the comment with the ID of 823423
46-
47-
4841 const comment = comments . find ( comment => comment . id === 823423 ) ;
49-
5042 console . log ( comment ) ;
5143
5244 // Array.prototype.findIndex()
53- // Find the comment with this ID
54- // delete the comment with the ID of 823423
45+ // Find the comment with this ID 823423 and delete it
5546 const index = comments . findIndex ( comment => comment . id === 823423 ) ;
56- console . log ( index ) ;
57-
58- // comments.splice(index, 1);
59-
6047 const newComments = [
6148 ...comments . slice ( 0 , index ) ,
6249 ...comments . slice ( index + 1 )
6350 ] ;
51+ console . log ( newComments )
6452
6553 </ script >
6654</ body >
67- </ html >
55+
56+ </ html >
0 commit comments