diff --git a/src/common/utils.tsx b/src/common/utils.tsx index 6ec36bb7..17df4b35 100644 --- a/src/common/utils.tsx +++ b/src/common/utils.tsx @@ -67,12 +67,11 @@ export const getImageSize = (url: string) => { }; }); }; -export const getInitials = (name: string) => { +export const getInitials = (name: string, length: number = 4) => { const arr = name.split(" ").filter((n) => !!n); - return arr - .map((t) => t[0]) - .join("") - .toUpperCase(); + const initialArr = arr.map((t) => [...t][0]); + initialArr.length = length; + return initialArr.join("").toUpperCase(); }; export const getInitialsAvatar = ({ initials = "UK",