Last active
September 27, 2019 16:24
-
-
Save johncmunson/aad81ed6f03e3da39ade3d3aa5a894f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Sometimes we do cool stuff like this... | |
let tacoType = hasQueso ? 'supreme' : 'normal' | |
// Or this in our markup... | |
`ng-class="isActive && 'md-primary'"` | |
// Or this to set default values... | |
this.color = config.color || 'blue' | |
// Sometimes though we'd like to have more | |
// options at our disposal when conditionally | |
// assigning to a variable. | |
// Enter the nested ternary. With some proper formatting, | |
// it actually reads quite nicely. | |
let dogSize = breed === 'rottweiler' ? 'big' : | |
breed === 'boxer' ? 'medium' : | |
breed === 'pug' ? 'small' : | |
'medium' // default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment