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>
1function lessThan100(a, b) {
2 let sum;
3 if (a + b >= 100) {
4 result = false;
5 } else {
6 result = true;
7 }
8 return result;
9}
1if ( expression )
2Here are some expressions and their result
3 Undefined: false
4 Null: false
5 Boolean: the result equals the input argument (no conversion)
6 Number: false if the argument is +0, -0, or NaN; otherwise true
7 String: false if the argument is an empty string (length = 0);
8 otherwise true
9 Object: true