You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
275 B
14 lines
275 B
export function capitalize(str) {
|
|
if (typeof str !== 'string') {
|
|
return '';
|
|
}
|
|
|
|
return str
|
|
.toLowerCase()
|
|
.split(/[ -_]/g)
|
|
.filter((word) => !!word)
|
|
.map((word) => {
|
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
})
|
|
.join(' ');
|
|
}
|
|
|