r/learnjavascript • • May 06 '21

JS: Multiple Condition Checking

Post image
484 Upvotes

61 comments sorted by

View all comments

Show parent comments

1

u/delventhalz May 07 '21

It's a small point. Depending on the review and the context, I might let it slide. OP's example is also a little too generic to really understand the use case.

All that said, I interpret the use case to be a complex multi-part conditional rather than a defined set of options. And in that case, I do think chaining conditionals pretty definitely requires less cognitive leaps. I can easily imagine juniors looking at that array and going "wait, why is there an array now?"

And while the cognitive load is smallish to context switch from "I am checking a series of conditionals" to "I am checking membership in a set", I don't really see any benefit to adding the extra complication.

1

u/jbonesinthecloset May 08 '21

But like...it is clear why there is an array...

1

u/delventhalz May 08 '21

To you?

1

u/jbonesinthecloset May 08 '21

Based on the comments for this entire post, it’s clear to pretty much everyone except you and your juniors

→ More replies (0)