11<!DOCTYPE html>
22< html lang ="en ">
3+
34< head >
4- < meta charset ="UTF-8 ">
5- < title > Array Cardio 💪💪</ title >
5+ < meta charset ="UTF-8 ">
6+ < title > Array Cardio 💪💪</ title >
67</ head >
8+
79< body >
8- < p > < em > Psst: have a look at the JavaScript Console</ em > 💁</ p >
9- < script >
10- // ## Array Cardio Day 2
11-
12- const people = [
13- { name : 'Wes' , year : 1988 } ,
14- { name : 'Kait' , year : 1986 } ,
15- { name : 'Irv' , year : 1970 } ,
16- { name : 'Lux' , year : 2015 }
17- ] ;
18-
19- const comments = [
20- { text : 'Love this!' , id : 523423 } ,
21- { text : 'Super good' , id : 823423 } ,
22- { text : 'You are the best' , id : 2039842 } ,
23- { text : 'Ramen is my fav food ever' , id : 123523 } ,
24- { text : 'Nice Nice Nice!' , id : 542328 }
25- ] ;
26-
27- // Some and Every Checks
28- // Array.prototype.some() // is at least one person 19 or older?
29- // Array.prototype.every() // is everyone 19 or older?
30-
31- // Array.prototype.find()
32- // Find is like filter, but instead returns just the one you are looking for
33- // find the comment with the ID of 823423
34-
35- // Array.prototype.findIndex()
36- // Find the comment with this ID
37- // delete the comment with the ID of 823423
38-
39- </ script >
10+ < p > < em > Psst: have a look at the JavaScript Console</ em > 💁</ p >
11+ < script >
12+ // ## Array Cardio Day 2
13+
14+ const people = [ {
15+ name : 'Wes' ,
16+ year : 1988
17+ } , {
18+ name : 'Kait' ,
19+ year : 1986
20+ } , {
21+ name : 'Irv' ,
22+ year : 1970
23+ } , {
24+ name : 'Lux' ,
25+ year : 2015
26+ } ] ;
27+
28+ const comments = [ {
29+ text : 'Love this!' ,
30+ id : 523423
31+ } , {
32+ text : 'Super good' ,
33+ id : 823423
34+ } , {
35+ text : 'You are the best' ,
36+ id : 2039842
37+ } , {
38+ text : 'Ramen is my fav food ever' ,
39+ id : 123523
40+ } , {
41+ text : 'Nice Nice Nice!' ,
42+ id : 542328
43+ } ] ;
44+
45+ // Some and Every Checks
46+ // Array.prototype.some() // is at least one person 19 or older?
47+ const isOver18 = people . some ( person => {
48+ const currentYear = new Date ( ) . getFullYear ( ) ;
49+ if ( ( currentYear - person . year ) > 18 ) return true ;
50+ } ) ;
51+ console . log ( {
52+ isOver18
53+ } )
54+ // Array.prototype.every() // is everyone 19 or older?
55+
56+ // Array.prototype.find()
57+ // Find is like filter, but instead returns just the one you are looking for
58+ // find the comment with the ID of 823423
59+
60+ // Array.prototype.findIndex()
61+ // Find the comment with this ID
62+ // delete the comment with the ID of 823423
63+ </ script >
4064</ body >
41- </ html >
65+
66+ </ html >
0 commit comments