conditional operator in if statement 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"