Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created May 28, 2013 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicapow/5666596 to your computer and use it in GitHub Desktop.
Save vicapow/5666596 to your computer and use it in GitHub Desktop.
multiple return statements
// 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