Skip to content

Instantly share code, notes, and snippets.

@kopepasah
Last active June 4, 2023 18:46
Show Gist options
  • Save kopepasah/d30ffaf660b26ef222d1170e109d79f3 to your computer and use it in GitHub Desktop.
Save kopepasah/d30ffaf660b26ef222d1170e109d79f3 to your computer and use it in GitHub Desktop.
Code examples for post https://koop.sh/?p=496
const people = [
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Frank",
"Grace",
"Heidi",
"Ivan",
"Judy"
];
let allowed = [
"Alice",
"Charlie",
"Eve",
"Grace",
"Judy"
];
for ( const person of people ) {
// Person knocks on door, and is greeted by security
if ( allowed.includes( person ) ) {
// Person is allowed to enter (we know this person is awesome!)
}
// Person is not allowed to enter
}
const disallowed = [
"Bob",
"David",
"Frank"
];
for ( const person of people ) {
// Person knocks on door, and is greeted by security
if ( ! disallowed.includes( person ) ) {
// Person is allowed to enter (hope they are not a troublemaker!)
}
// Person is not allowed to enter
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment