Skip to content

Instantly share code, notes, and snippets.

@eduardocruz
Created February 9, 2015 22:26
Show Gist options
  • Save eduardocruz/d94155dc0059b0f47bba to your computer and use it in GitHub Desktop.
Save eduardocruz/d94155dc0059b0f47bba to your computer and use it in GitHub Desktop.
Removing Unnecessary ELSE
//BEFORE
function myFunction()
{
if(userAuthorized())
{
execute();
execute();
execute();
execute();
} else {
return "Unauthorized Access";
}
}
//AFTER
function myFunction()
{
if( ! userAuthorized() )
return "Unauthorized Access";
execute();
execute();
execute();
execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment