Skip to content

Instantly share code, notes, and snippets.

Last active September 27, 2019 16:24
  • 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
What would you like to do?
// 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