You’re mixing two different conditional syntaxes here when you could have used 1. It took my brain a minute to even recognize you had a ternary inside the if statement body.

If you had instead used a chained ternary, it would have been much easier for me to read, because my brain wouldn’t need to context switch between syntax reading modes.

The “nested ternaries R bad” dogma is just wrong. I know a lot of people agree with it but I’m convinced that it’s familiarity bias. Chained ternaries are less common and for that main reason, people have less practice reading them.

Written by

Make some magic. #JavaScript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store