Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions 07 - Array Cardio Day 2/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,37 @@

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

const ageCheck = people.every(person =>
((new Date()).getFullYear()) - person.year >= 19);

let groupOk = '<div id = "message">Group is OK</div>';
let groupNotOk = '<div id = "message">Group is not OK</div>';

/*verifyGroup = ageCheck ? document.getElementbyId("body").innerHTML = groupOk : document.getElementbyId("body").innerHTML = groupNotOk;

document.body.appendChild(document.createTextNode(verifyGroup));*/

console.log(ageCheck);

// Array.prototype.find()
// Find is like filter, but instead returns just the one you are looking for
// find the comment with the ID of 823423

const comment = comments.find(comment =>
comment.id === 823423
);

console.log(comment);

// Array.prototype.findIndex()
// Find the comment with this ID
// delete the comment with the ID of 823423

const index = comments.findIndex(comment =>
comment.id === 823423);

comments.splice(index, 1);

</script>
</body>
</html>