-
-
Save Amir-A-M/3f43cedaaa57472150e234e121f097cd to your computer and use it in GitHub Desktop.
confusing code return early pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function returnStuff(argument1, argument2) { | |
| if (argument1.isValid()) { | |
| if (argument2.isValid()) { | |
| const otherVal1 = doSomeStuff(argument1, argument2); | |
| if (otherVal1.isValid()) { | |
| const otherVal2 = doAnotherStuff(otherVal1); | |
| if (otherVal2.isValid()) { | |
| return "Stuff"; | |
| } else { | |
| throw new Exception(); | |
| } | |
| } else { | |
| throw new Exception(); | |
| } | |
| } else { | |
| throw new Exception(); | |
| } | |
| } else { | |
| throw new Exception(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment