Created
September 12, 2011 18:29
-
-
Save OscarGodson/1211993 to your computer and use it in GitHub Desktop.
Multiple expressions in the ternary operator
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
//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