Last active
April 8, 2021 15:24
-
-
Save jondashkyle/b9330641247b9bd67669445865c44a40 to your computer and use it in GitHub Desktop.
Switch it up
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
// Pseudo-code of a pattern I use frequently. | |
const theTitle = 'Seeing is forgetting the name of the thing one sees' | |
const isActive = true | |
const duration = 420 | |
switch (true) { | |
case !!theTitle: | |
return 'Has a title!' | |
case isActive && duration > 300: | |
return 'Active with medium duration' | |
case !!theTitle && !isActive: | |
case duration < 100 && !isActive: | |
return 'Has a title, but not active, or short and active' | |
default: | |
return 'Whatever!' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment