Skip to content

Instantly share code, notes, and snippets.

@1000hz
Created April 18, 2014 20:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1000hz/11062671 to your computer and use it in GitHub Desktop.
Save 1000hz/11062671 to your computer and use it in GitHub Desktop.
Nested ternaries can be nice if you do it right...
function dessertRank(dessert) {
return dessert === "muffins" ? "good"
: dessert === "brownies" ? "pretty good"
: dessert === "cupcakes" ? "great"
: dessert === "cookies" ? "amazing"
: dessert === "cake" ? "omg"
: dessert === "ice cream" ? "dying"
: "probably pretty great"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment