Last active
March 30, 2017 22:41
-
-
Save jschwarty/8c364bce27ae9ed1eae990587af27bf2 to your computer and use it in GitHub Desktop.
Function to create initials from a list of strings.
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
export function buildInitials(...fields: string[]) { | |
return fields.reduce((acc, val) => { | |
acc += val.length > 0 ? val[0] : ''; | |
return acc.toUpperCase(); | |
}, ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment