Using the Ternary Operator for Conditional Logic in Javascript


The ternary operator provides a shorthand way of writing an if-else statement.

Source Code

let isAdult = age >= 18 ? 'Yes' : 'No';
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments