Skip to content

Commit 427098d

Browse files
committed
challenge 7 + readme complete
1 parent 8f769e3 commit 427098d

3 files changed

Lines changed: 24 additions & 22 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Exercise 7: Array Cardio Day 2
2+
Nitish Dayal, Software & Applications Developer - [Contact](http://nitishdayal.me)
3+
Last Commit Date: Dec 12, 2016
4+
5+
More fun with Array methods! Much like the previous Array Cardio exercise, the
6+
requirements are pretty well documented. This exercise utilizes the following
7+
built-in Array methods:
8+
- [Array.prototype.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
9+
- [Array.prototype.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
10+
- [Array.prototype.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
11+
- [Array.prototype.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
12+
13+
Learn 'em, tuck 'em away in your back pocket, remember where they are and what they do!
Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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
@@ -24,44 +26,31 @@
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>

‎readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Completed written guides can be found in the corresponding challenge directory (
3434
4. [x] ~~[Array Cardio, Day 1](./exercises/04\ -\ Array\ Cardio\ Day\ 1/)~~
3535
5. [x] ~~[Flex Panel Gallery](./exercises/05\ -\ Flex\ Panel\ Gallery/)~~
3636
6. [x] ~~[Type Ahead](./exercises/06\ -\ Type\ Ahead/)~~
37-
7. [ ] Array Cardio, Day 2
37+
7. [x] ~~[Array Cardio, Day 2](./exercises/07\ -\ Array\ Cardio\ Day\ 2/)~~
3838
8. [ ] Fun with HTML5 Canvas
3939
9. [ ] Dev Tools Domination
4040
10. [ ] Hold Shift and Check Checkboxes

0 commit comments

Comments
 (0)