File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 28
28
// Array.prototype.some() // is at least one person 19 or older?
29
29
// Array.prototype.every() // is everyone 19 or older?
30
30
31
+ console . log ( 'is at least one person 19 or older? The anwer is: ' + people . some ( kid => ( 2017 - kid . year > 18 ) ) ) ;
32
+ console . log ( 'is everyone 19 or older? The anwer is: ' + people . every ( kid => ( 2017 - kid . year > 18 ) ) ) ;
33
+
31
34
// Array.prototype.find()
32
35
// Find is like filter, but instead returns just the one you are looking for
33
36
// find the comment with the ID of 823423
37
+ let txt = comments . find ( comment => comment . id === 823423 ) . text ;
38
+ console . log ( txt ) ;
34
39
35
40
// Array.prototype.findIndex()
36
41
// Find the comment with this ID
37
42
// delete the comment with the ID of 823423
43
+ let idx = comments . findIndex ( comment => comment . id === 823423 ) ;
44
+ console . log ( 'the index of the id 823423 is ' + idx ) ;
45
+ let comments_new = [
46
+ ...comments . slice ( 0 , idx ) ,
47
+ ...comments . slice ( idx + 1 )
48
+ ]
49
+
50
+ let newResult = [ ] ;
51
+ comments_new . map ( i => newResult . push ( i . text ) )
52
+ console . log ( 'after delete it, the comments are [' + newResult . join ( ', ' ) + '] now' ) ;
53
+
38
54
39
55
</ script >
40
56
</ body >
Original file line number Diff line number Diff line change 10
10
4 . [x] ~~ Array Cardio, Day 1~~
11
11
5 . [x] ~~ Flex Panel Gallery~~
12
12
6 . [x] ~~ Type Ahead~~
13
- 7 . [ ] Array Cardio, Day 2
13
+ 7 . [x] ~~ Array Cardio, Day 2~~
14
14
8 . [ ] Fun with HTML5 Canvas
15
15
9 . [ ] Dev Tools Domination
16
16
10 . [ ] Hold Shift and Check Checkboxes
You can’t perform that action at this time.
0 commit comments