-
-
Save kopepasah/d30ffaf660b26ef222d1170e109d79f3 to your computer and use it in GitHub Desktop.
Code examples for post https://koop.sh/?p=496
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const people = [ | |
"Alice", | |
"Bob", | |
"Charlie", | |
"David", | |
"Eve", | |
"Frank", | |
"Grace", | |
"Heidi", | |
"Ivan", | |
"Judy" | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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