DEV Community 👩‍💻👨‍💻

Discussion on: Towards zero bugs

Collapse
 
qm3ster profile image
Mihail Malo • Edited on

Hewwo, pwease change

- if (hidden) { show(); } else { hide(); }
+ if (hidden) { hide(); } else { show(); }`.

if hidden is the current state.
OR, if hidden is desired state, change

- if (!hidden) { show(); } else { hide(); }
+ if (!hidden) { hide(); } else { show(); }

You didn't flip the cases when negating the predicate.

Stylistically I would ofc prefer one of:

if (hidden) show()
else hide()

or

hidden ? show() : hide()

for a better signal/noise ratio (which makes bugs more evident)

Thread Thread
 
conw_y profile image
Jonathan Author

Apologies for the delay. I've fixed the logic error you rightly pointed out.