Conditional (Ternary) Operator for Concise Conditionals in Javascript


Use the ternary operator for simple if-else conditions.

Source Code

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