condensed if statement javascirpt code example
Example 1: js ternary
condition ? ifTrue : ifFalse
Example 2: how to use ternary operator in javascript
var age = 26;
var beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"
condition ? ifTrue : ifFalse
var age = 26;
var beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"