webapp/src/utils/capitalize.ts
2023-12-20 10:45:29 +03:00

10 lines
290 B
TypeScript

export const capitalize = (originalString: string, firstonly = false) => {
const s = (originalString || '').trim()
return firstonly
? s.charAt(0).toUpperCase() + s.slice(1)
: s
.split(' ')
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
.join(' ')
}