ternary as typescript code example
Example 1: ternary operator javascript
condition ? exprIfTrue : exprIfFalse
//Example
let age = 26;
let beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"
Example 2: how to use ternary operator in javascript
var age = 26;
var beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"