Skip to content

Instantly share code, notes, and snippets.

@OscarGodson
Created September 12, 2011 18:29
Show Gist options
  • Save OscarGodson/1211993 to your computer and use it in GitHub Desktop.
Save OscarGodson/1211993 to your computer and use it in GitHub Desktop.
Multiple expressions in the ternary operator
//NOTE: don't use semicolon inside a ternary, use a comma like so:
x == 1 //If x == 1
? alert(x) //Alert 1
:( //Else...
alert('Error'), //alert an error
x = 1, //Change x to 1
alert('All Fixed!') //Alert the user again, say it's fixed
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment