Created
October 5, 2013 21:20
-
-
Save tyrotinal/6846183 to your computer and use it in GitHub Desktop.
js - 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
var a = 2; | |
var b = 3; | |
var c = 4; | |
function sayHi(){ | |
console.log("hello - a"); | |
} | |
function sayHiB(){ | |
console.log("hello - B"); | |
} | |
function sayHiC(){ | |
console.log("hello - C"); | |
} | |
function sayHiElse(){ | |
console.log("hello - Else"); | |
} | |
a == 3? sayHi() : b == 4? sayHiB() : c == 5? sayHiC() : sayHiElse(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment