r/badcode • sadistic • Apr 22 '21

js ternary operators at their maximum potential

Post image
960 Upvotes

73 comments sorted by

View all comments

7

u/INTO_NIGHT Apr 22 '21

I thought the rule for ternary was have only two things compared not even sure what this would return

23

u/fukitol- Apr 22 '21

The else clause of every ternary operator here is another ternary operator. It'd work, but everyone would hate you and make fun of you for this.

6

u/CrepuscularSoul Apr 22 '21

Basically yeah. I love ternary for simple one line if else stuff, I might let a second nested one slide if it's formatted for readability, but beyond that I'm not approving that PR.