Created
May 28, 2013 22:17
-
-
Save vicapow/5666596 to your computer and use it in GitHub Desktop.
multiple return statements
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
// good | |
function example1() { | |
if(someCondition) return thing1 | |
else if (someOtherCondition) return thing2 | |
else return thing3 | |
} | |
// bad | |
function example2() { | |
var retval; | |
if(!someCodition) { | |
if(!someOtherCondition) { | |
retval = thing3; | |
}else { | |
retval = thing2; | |
} | |
} else { | |
retval = thing1; | |
} | |
return retval; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment