ts-utils
  • Getting Started
  • Contributing
  • Testing
  • Functions
    • Array Methods
      • isArr
      • isArrEmpty
      • pushUniqueValue
      • pushOrUpdate
    • Date Methods
      • toNow
      • formatDate
      • fromNow
    • Number Methods
      • toFixed
      • parseNumber
      • parseFormat
      • addUnit
      • addSeparators
      • formatNumber
      • ensureNumber
      • numberEmptyState
    • Object Methods
      • parseJSON
      • deepClone
      • parseNumValues
      • removeEmptyKeys
      • sanitizeQuery
      • removeKeys
      • renameKey
      • renameKeys
      • sortByKeyLength
      • querylize
      • parseNumericObj
      • reserveKeys
      • hasKeysAndValues
    • String Methods
      • randomStr
      • toUpperCase
      • toLowerCase
      • toFullUrl
      • initials
      • generateUuid
Powered by GitBook
On this page
  • initials(str)
  • Arguments
  • Returns
  • Example
  • Usage
  • Notes

Was this helpful?

  1. Functions
  2. String Methods

initials

initials(str)

Generates the initials from a person's name. This function extracts the initials of each word in the input string representing the person's name and separates them with periods.

Arguments

  • str (string): The input string representing the person's name.

Returns

  • string: The initials of the person's name, with each initial separated by a period.

Example

typescript
import { initials } from 'check-engineering/ts-utils';

const fullName = "John Doe";
const nameInitials = initials(fullName); // => "J.D"

Usage

typescript
import { initials } from 'check-engineering/ts-utils';

const userName = "Alice Wonderland";
const userInitials = initials(userName); // => "A.W"

Notes

  • The initials function extracts the initials from a person's name by taking the first letter of each word and converting it to uppercase.

  • It then joins these initials with periods to create a formatted representation of the person's name.

  • This function is useful for scenarios where abbreviated names or initials are required, such as in user profiles or display names.

PrevioustoFullUrlNextgenerateUuid

Last updated 11 months ago

Was this helpful?