Nested ternaries aren’t good or bad


Nested ternaries aren’t good or bad. They’re contextual.

A nested ternary that contains 100’s of lines of code? Yuck. 🤮

A nested ternary that contains a few lines of simple code? Fine by me.

Example:

That said, often a map is an elegant alternative to a nested ternary.

Example:

View original on X