DEV Community

Discussion on: If/else or just if?

Collapse
 
tarialfaro profile image
Tari R. Alfaro • Edited

Which ever route is the easiest to read(usually it's the second one) is the one I pick. Less code is more.

I've worked with both a lot, and I find the second one is often better for my cognitive load. If you need if/else/elseif perhaps to many things are going on at once.

It depends on what kind of logic is needed, and which one reduces the amount of code and improves the readability.