Tip 18: Check Data Quickly with the Ternary Operator

In this tip, you’ll learn how to avoid reassignment with the ternary operator.

The ternary operator

By now, you may have noticed that I love simple code. I’ll always try to get an expression reduced down to the fewest characters I can. I blame a former coworker who reviewed some code I wrote at one of my first jobs.

Get hands-on with 1200+ tech skills courses.