Skip to content

Instantly share code, notes, and snippets.

@kopepasah
Last active June 4, 2023 18:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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