mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-02 13:58:18 -05:00
Add capitalize
This commit is contained in:
12
lib/format.ts
Normal file
12
lib/format.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
function capitalizeOne(str: string) {
|
||||
if (!str) return "";
|
||||
return str[0].toUpperCase() + str.slice(1).toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
export function capitalize(str: string) {
|
||||
return str
|
||||
.split(" ")
|
||||
.map(word => capitalizeOne(word))
|
||||
.join(" ");
|
||||
}
|
||||
Reference in New Issue
Block a user