Using the Ternary Operator for Quick Decisions in Javascript


The ternary operator is a shorthand for if-else statements.

Source Code

let age = 20;
let beverage = age >= 18 ? "Beer" : "Juice";
console.log(beverage); // "Beer"
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments