Skip to content

Commit 1c26a30

Browse files
author
William Coleman
authored
Merge pull request #15 from wcski/array-cardio-2
Array cardio 2
2 parents ceea0fd + 03b0c92 commit 1c26a30

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,37 @@
3434

3535
// Array.prototype.every() // is everyone 19 or older?
3636

37+
const ageCheck = people.every(person =>
38+
((new Date()).getFullYear()) - person.year >= 19);
39+
40+
let groupOk = '<div id = "message">Group is OK</div>';
41+
let groupNotOk = '<div id = "message">Group is not OK</div>';
42+
43+
/*verifyGroup = ageCheck ? document.getElementbyId("body").innerHTML = groupOk : document.getElementbyId("body").innerHTML = groupNotOk;
44+
45+
document.body.appendChild(document.createTextNode(verifyGroup));*/
46+
47+
console.log(ageCheck);
48+
3749
// Array.prototype.find()
3850
// Find is like filter, but instead returns just the one you are looking for
3951
// find the comment with the ID of 823423
4052

53+
const comment = comments.find(comment =>
54+
comment.id === 823423
55+
);
56+
57+
console.log(comment);
58+
4159
// Array.prototype.findIndex()
4260
// Find the comment with this ID
4361
// delete the comment with the ID of 823423
4462

63+
const index = comments.findIndex(comment =>
64+
comment.id === 823423);
65+
66+
comments.splice(index, 1);
67+
4568
</script>
4669
</body>
4770
</html>

0 commit comments

Comments
 (0)