The Ternary Operator

In this lesson, we'll understand how the ternary operator serves as a substitute for the if-else expression.

We'll cover the following

Much like the if-else expression, the ternary operator is used when our condition has two possible outcomes. It is generally represented by the ?: characters.

The Structure

A ternary expression asks a question, and then presents two possible expressions to be executed:

Get hands-on with 1200+ tech skills courses.