Skip to content

Instantly share code, notes, and snippets.

@ktravers
Last active July 12, 2018 03:00
Show Gist options
  • Save ktravers/1d1d706c5626c41c9675e49b37705eee to your computer and use it in GitHub Desktop.
Save ktravers/1d1d706c5626c41c9675e49b37705eee to your computer and use it in GitHub Desktop.
export const displayName = (user) => {
if (user.firstName.length > 0) {
if (user.lastName.length > 0) {
return `${user.firstName} ${user.lastName}`.trim();
} else {
return `${user.firstName}`.trim();
}
} else if (user.username.length > 0) {
return user.username;
} else {
return 'New User';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment