Last active
November 17, 2019 03:00
-
-
Save taingmeng/5ca90f12aed30b906dc0090452f69ca9 to your computer and use it in GitHub Desktop.
Example of bad nested condition
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
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