Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
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
10 changes: 10 additions & 0 deletions 10 07 - Array Cardio Day 2/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,25 @@

// Some and Every Checks
// Array.prototype.some() // is at least one person 19 or older?
const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19);
console.log("Any adults?", isAdult);

// Array.prototype.every() // is everyone 19 or older?
const allAdults = people.every(person => ((new Date()).getFullYear()) - person.year >= 19);
console.log("All adults?", allAdults);

// 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(c => c.id === 823423);
console.log("Comment 823423", comment);

// Array.prototype.findIndex()
// Find the comment with this ID
// delete the comment with the ID of 823423
const purgeIndex = comments.findIndex(c => c.id === 823423);
comments.splice(purgeIndex, 1);
console.log("purge 823423", comments);

</script>
</body>
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.