Skip to content

Instantly share code, notes, and snippets.

@Aeon
Created November 30, 2012 01:29
Show Gist options
  • Save Aeon/4173148 to your computer and use it in GitHub Desktop.
Save Aeon/4173148 to your computer and use it in GitHub Desktop.
js refactoring...
var should_reset = false;
if (condition1) {
alert(1);
}else if (condition2) {
alert(2);
should_reset = true;
}else if (condition3) {
alert(3);
should_reset = true;
}else{
return true;
}
if(should_reset) {
reset();
}
if (condition1) {
alert(1);
}else if (condition2 || condition3) {
if(condition2) {
alert(2);
} else {
alert(3);
}
reset();
}else{
return true;
}
if(condition2 || condition3) {
reset();
}
if (condition1) {
alert(1);
}else if (condition2) {
alert(2);
}else if (condition3) {
alert(3);
}else{
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment