️ feat: create getInitials util function

This commit is contained in:
Wahyu Kurniawan 2024-02-27 20:41:40 +07:00
parent 4ca1a4bcfd
commit 44e38740a2
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33

View File

@ -0,0 +1,13 @@
/**
* Get initials from a full name.
*
* @param {string} name - The full name string from which to get the initials.
* @returns {string} A string of initials.
*/
export function getInitials(name: string): string {
return name
.split(' ')
.filter((n) => n)
.map((n) => n[0].toUpperCase())
.join('');
}