I don't know what to post.<p>1) arguing about syntax is awful and this thread will be worse for it<p>2) opinionated tools like Prettier are meant to prevent such discussions<p>3) this post is such discussion bait<p>4) I super hate that formatting<p>I would never nest ternaries that many levels deep, but this always worked for me and I consider it a solved problem:<p><pre><code> const animalName =
pet.canSqueak()
? 'mouse'
: pet.canBark()
? pet.isScary()
? 'wolf'
: 'dog'
: pet.canMeow()
? 'cat'
: pet.canSqueak()
? 'mouse'
: 'probably a bunny';
</code></pre>
I reproduce it verbatim, but want to point out the last `pet.canSqueak()` branch is not needed. Maybe that was done on purpose?<p>Almost no tools can do it and it drives me nuts.<p>Everything breaks down when the predicates end up multi-line though, and I don't see this particular style improving it.