ternany expression code example
Example 1: ternary operator
(condition) ? (if true, do this) : (otherwise, do this)
Example 2: conditional operator
var age = 26;
var beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"
(condition) ? (if true, do this) : (otherwise, do this)
var age = 26;
var beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"