Self-Do-Unto A-Code: Ternary Operators 101

Ternary Operator: Because 2 Options are Not Enough

When in code, you're faced with a yes or no answer, but what about when there are three options?

Enter the mighty Ternary Operator: ??.

Think of it like a traffic light: Red, Yellow, and Green. Which light will you turn on?

See it in action with a traffic light example!

Or, maybe, you're a master of the Ternary Operator and want to show off your skills?

Go from Ternary to Conditional Statements: The Real Powerhouse of Programming.

Code Examples:

      
        var answer = 1 ? "Yes" : 0;
        var answer2 = 2 ? "Maybe" : "No";
        var answer3 = 3 ? "Definitely" : "Not a Chance";