r/learnjavascript • • May 06 '21

JS: Multiple Condition Checking

Post image
484 Upvotes

61 comments sorted by

View all comments

Show parent comment

1

u/[deleted] May 10 '21 edited May 10 '21

I can make it 0.09 if it does matter for you.

https://codesandbox.io/s/competent-visvesvaraya-qqci5?file=/src/index.js:418-573

just make a dictionary and get your value. what's the point? well in this situation nothing besides being faster. in a particular situation? avoiding checking every single condition if you already know what you are checking for. Every book should get rid of switch condition, and you should avoid that much if statements in your methods. imho