Skip to content

Commit bd8ee13

Browse files
author
Jin Xu
committed
course wesbos#7 finished
1 parent 68edd48 commit bd8ee13

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

07 - Array Cardio Day 2/index-START.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,29 @@
2828
// Array.prototype.some() // is at least one person 19 or older?
2929
// Array.prototype.every() // is everyone 19 or older?
3030

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+
3134
// Array.prototype.find()
3235
// Find is like filter, but instead returns just the one you are looking for
3336
// find the comment with the ID of 823423
37+
let txt = comments.find(comment => comment.id === 823423).text;
38+
console.log(txt);
3439

3540
// Array.prototype.findIndex()
3641
// Find the comment with this ID
3742
// 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+
3854

3955
</script>
4056
</body>

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
4. [x] ~~Array Cardio, Day 1~~
1111
5. [x] ~~Flex Panel Gallery~~
1212
6. [x] ~~Type Ahead~~
13-
7. [ ] Array Cardio, Day 2
13+
7. [x] ~~Array Cardio, Day 2~~
1414
8. [ ] Fun with HTML5 Canvas
1515
9. [ ] Dev Tools Domination
1616
10. [ ] Hold Shift and Check Checkboxes

0 commit comments

Comments
 (0)