Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

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;

You might also like