The first statement in the ternary operator is a condition and is followed by the operator ?
, which stands in for the if
keyword. The :
represents else
.
If the condition is true
, the code before the :
will be executed. If it is false
, the code after the :
will run. Cool huh!?
An if statement is basically a question, isn't it ?