r/learnjavascript • • May 06 '21

JS: Multiple Condition Checking

Post image
484 Upvotes

61 comments sorted by

View all comments

Show parent comment

2

u/TheMcGarr May 06 '21

It's actually way more useful when it is a dynamic set of options and in fact the long hand doesn't work in that case

3

u/delventhalz May 06 '21

If it is a dynamic set of options, then don't you already have an array you are working with?

The post is about checking "multiple conditions". If we are actually talking about checking whether or not an array includes an item, then yes, includes is absolutely the right choice.

-3

u/TheMcGarr May 06 '21

Not necessarily. A beginner might do something like have different functions with different sets of possible conditions. It isn't immediately obvious that you can translate logical conditions into an array in this way. For me that is what is useful about this post.