1condition ? doThisIfTrue : doThisIfFalse
2
31 > 2 ? console.log(true) : console.log(false)
4// returns false
1var age=20;
2if (age < 18) {
3 console.log("underage");
4} else {
5 console.log("let em in!");
6}
1//XCal - Javascript Inline Conditional Sample (condition brackets only for clarity)
2// v-? = Conditional Operator
3// v v-: = True/False result value separator
4//Format = v-Condition-v ? v-When True-v : v-When False-v
5var vResult = (null == null) ? 'Condition True' : 'Condition False';
6//vResult is now 'Condition True';
1// example:
2age >= 18 ? `wine` : `water`;
3
4// syntax:
5// <expression> ? <value-if-true> : <value-if-false>