1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
+
3
4
< head >
4
- < meta charset ="UTF-8 ">
5
- < title > Array Cardio 💪💪</ title >
5
+ < meta charset ="UTF-8 ">
6
+ < title > Array Cardio 💪💪</ title >
6
7
</ head >
8
+
7
9
< 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 isAdult = people . some ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
48
+
49
+ /*console.log({
50
+ isAdult
51
+ });*/
52
+
53
+ // Array.prototype.every() // is everyone 19 or older?
54
+ const allAdults = people . every ( person => ( ( new Date ( ) ) . getFullYear ( ) ) - person . year >= 19 ) ;
55
+
56
+ /*console.log({
57
+ allAdults
58
+ });*/
59
+
60
+ // Array.prototype.find()
61
+ // Find is like filter, but instead returns just the one you are looking for
62
+ // find the comment with the ID of 823423
63
+ const comment = comments . find ( com => com . id === 823423 ) ;
64
+
65
+ // console.log(comment);
66
+
67
+ // Array.prototype.findIndex()
68
+ // Find the comment with this ID
69
+ // delete the comment with the ID of 823423
70
+ const index = comments . findIndex ( com => com . id === 823423 ) ;
71
+
72
+ /*comments.splice(index, 1);
73
+
74
+ console.log(index);
75
+ console.table(comments);*/
76
+ </ script >
40
77
</ body >
41
- </ html >
78
+
79
+ </ html >
0 commit comments