terinary operator js code example
Example 1: js ternary
condition ? ifTrue : ifFalse
Example 2: ternary function javascript
var variable;
if (condition)
variable = "something";
else
variable = "something else";
var variable = condition ? "something" : "something else";
Example 3: ternary operator in javascript
FullName: (obj.FirstName && obj.LastName) ? obj.FirstName + " " + obj.LastName : "missing values",
Example 4: ternary operator javascript
condition ? exprIfTrue : exprIfFalse
let age = 26;
let beverage = (age >= 21) ? "Beer" : "Juice";
console.log(beverage);