JavaScript Ternary Operator
I have included two ways of writing conditionals ( if/else, switch ) and this Ternary Operator is another one.
As you can see above, it does not look familiar but much simpler way of writing conditional. This is basically if age ≥ then display “You can get a driver license. Otherwise, display “You are not eligible to get a driver license”.
Initial variable age is already above 18 so that it displays the first line.
This is basically the same as the above operator and it displays the same result.
One more useful feature of this operator is that you can even use it in the template literal because it is an expression not a statement.
You cannot use if/else statement inside the template literal.