Skip to content

Commit 18fe230

Browse files
refactor: extract variables for first and last initial (laravel#30)
1 parent 5372068 commit 18fe230

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

resources/js/hooks/use-initials.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ export function useInitials() {
55
if (names.length === 0) return '';
66
if (names.length === 1) return names[0].charAt(0).toUpperCase();
77

8-
return `${names[0].charAt(0)}${names[names.length - 1].charAt(0)}`.toUpperCase();
8+
const firstInitial = names[0].charAt(0);
9+
const lastInitial = names[names.length - 1].charAt(0);
10+
11+
return `${firstInitial}${lastInitial}`.toUpperCase();
912
};
1013

1114
return getInitials;

0 commit comments

Comments
 (0)