webapp/src/utils/capitalize.ts

10 lines
290 B
TypeScript
Raw Normal View History

export const capitalize = (originalString: string, firstonly = false) => {
2023-12-20 07:45:29 +00:00
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(' ')
}