The ternary operator or conditional operator can be use as a short version of th e if-then-else statement.

When you have a simple if-then-else statement in your code that return a value you might use the ternary operator, it can make your co de easier to read. The ternary operator is written using the symbol of ?: and it has the following syntax: result = testCondition ? value1 : value2;

Sign up to vote on this title
UsefulNot useful