- You have a group of nested conditionals and it’s hard to determine the normal flow of code execution. A guard clause is simply a check that immediately exits the function, either with a return statement or an exception
- The code is more readable and understandable.
- Use guard clauses.
- Select outermost condition that needs to be replaced nad change it into guard clause.
- Test
Before
