this post was submitted on 11 Dec 2023
32 points (79.6% liked)

JavaScript

1700 readers
47 users here now

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] BrianTheeBiscuiteer@lemmy.world 1 points 6 months ago* (last edited 6 months ago)

Seems a bit shitty they mention the article by Eric Elliott (one of the first search results if you search "nested ternaries") but they don't take his advice.

This doesn't seem ugly to me at all (left out animal so I didn't have to type as much):

const animalType =
  canBark() && isScary() ? 'wolf'
  : canBark() ? 'dog'
  : canMeow() ? 'cat'
  : 'rabbit';