how to add ternary operator in javascript code example
Example 1: javascript ternary
// example:
age >= 18 ? `wine` : `water`;
// syntax:
// <expression> ? <value-if-true> : <value-if-false>
Example 2: how to use ternary operator in javascript
var age = 26;
var beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage); // "Beer"