• BrianTheeBiscuiteer@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    9 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';
    
  • hoot@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    I’ll be sending this article to my dev teams. It’s right up there with “stop writing Helper classes”.