2024-11-13 20:16:35 -05:00
|
|
|
/**
|
|
|
|
|
* Helper function to get first letter capitalized string
|
|
|
|
|
* @param {string} str String whose first letter is to be capitalized
|
|
|
|
|
* @returns A string with first letter capitalized
|
|
|
|
|
*/
|
2024-11-15 14:49:27 -05:00
|
|
|
export const capitalizeFirstLetter = (str) => {
|
|
|
|
|
if (str === null || str === undefined) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
if (typeof str !== "string") {
|
|
|
|
|
throw new TypeError("Input must be a string");
|
|
|
|
|
}
|
|
|
|
|
if (str.length === 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
|
|
|
};
|