A ternary operator is a shorthand way of writing an if-else statement in programming. It allows you to evaluate a condition and return one value if the condition is true and another value if it’s false, all in a single line.
The syntax for the ternary operator is:
(condition) ? value_if_true : value_if_false;