Skip to main content

getShortName()

function getShortName(fullName: string): string;

Returns a person's first name and the initial of their last name, such as Richard A. for Richard Dean Anderson.

  • Status text is left out as it is for getFirstName, so Ada Lovelace (OOO Friday) gives Ada L., not Ada F..
  • The initial comes from the last word rather than the second, because in a name of three or more words the last one is usually the family name.
  • The initial is a whole character as the reader sees it, so an accent or an Indic conjunct stays with its letter: Shreya श्रीवास्तव gives Shreya श्री..
  • A word that doesn't start with a letter, such as a trailing emoji, is skipped, so Ana Silva 🌴 gives Ana S.. When no word after the first starts with a letter, as in Robot 🤖 or a one-word name, the first name is returned alone.

Parameters​

ParameterTypeDescription
fullNamestringThe person's full name, such as a user's name or fullName

Returns​

string

The first name and last initial, the first name alone when there's no initial, or an empty string for a blank name