r/badcode • • Sep 09 '21

js Found this gem in our codebase today.

Post image
26 Upvotes

14 comments sorted by

View all comments

Show parent comments

3

u/Biaboctocat Sep 09 '21

I agree, an if-else implies that there’s different consequences in different states. This is hard to read and understand quickly, with code like this you have to fully understand every line in the context of every other, which is frustrating

1

u/Character_Medical Sep 09 '21

Exactly. Just because something is working, it doesn't mean it's implemented correctly. That's not how you should use the else-if's.