pnpm-test/src/core/utils/common.util.ts

12 lines
337 B
TypeScript

const getNameInitials = (name: string): string => {
if (!name?.trim()) return "";
const parts = name.trim().split(/\s+/);
const first = parts[0]?.[0]?.toUpperCase() ?? "";
const last = (parts.length > 1 ? parts[parts.length - 1]?.[0]?.toUpperCase() : "") ?? "";
return first + last;
};
export { getNameInitials };