Adding Ternary Operators to the mix
Here’s an example:
The code snippet above evaluates the condition of the boolean ‘isMorning’ to determine which expression should be displayed to the user. If ‘isMorning’ conditional check is true, the first expression is displayed, otherwise the second condition is displayed.
The syntax is a condition separated by a question mark (*?*) followed by expression 1 (can be interpreted as the if condition), which is separated by a colon(*:*) then followed by expression 2 (which can be interpreted as the else condition).
So a translation from the Ternary Operation to an IF Statement would be: