20
A senior dev told me to stop nesting my if statements, and it saved my code
They pointed out 6 levels deep in my JavaScript and said 'return early or switch to a map.' Has anyone else had a 'simple' tip that made you rewrite your whole approach?
2 comments
Log in to join the discussion
Log In2 Comments
the_charles22d ago
You ever look back at your old code and cringe? I had a mentor tell me to stop writing else statements entirely for a month. It forced me to think about every branch and whether it actually needed to exist. Now my functions are flat and way easier to test.
3
the_charles22d ago
OH MAN. Getting told to just STOP writing else statements sounds TERRIFYING but also kind of brilliant honestly.
3