Skip to content

Instantly share code, notes, and snippets.

@taingmeng
Last active November 17, 2019 03:00
Show Gist options
  • Save taingmeng/5ca90f12aed30b906dc0090452f69ca9 to your computer and use it in GitHub Desktop.
Save taingmeng/5ca90f12aed30b906dc0090452f69ca9 to your computer and use it in GitHub Desktop.
Example of bad nested condition
const hasAccessToPhoto = (user, photo) => {
if (photo.privacy !== 'public') {
if (user.role !== 'admin') {
if (photo.userId !== user.id) {
return photo.user.friends.includes(user.id) || photo.taggedUsers.includes(user.Id);
}
}
}
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment