condition1 ? condition2 ? Expression1 : Expression2 : Expression3
In the above syntax, we have tested 2 conditions in a single statement using the ternary operator. In the syntax, if condition1 is incorrect then Expression3 will be executed else if condition1 is correct then the output depends on the condition2. If condition2 is correct, then the output is Expression1. If it is incorrect, then the output is Expression2.
In the above syntax, we can see how we can use more than one ternary operator in a single statement. Below is an example explaining how we can use 2 ternary operators in a single statement.
You are between 30 and 69
Entered number is positive