const ucFirst = (str: string) =>
str
.split("")
.map((v, i) => (i === 0 ? v.toUpperCase() : v))
.join("");
const lcFirst = (str: string) =>
str
.split("")
.map((v, i) => (i === 0 ? v.toLowerCase() : v))
.join("");
const ucWords = (str: string) =>
str
.split(" ")
.map((i) => ucFirst(i))
.join(" ");
Created
March 10, 2022 04:37
-
-
Save arisris/948faf69c0da6c913472cd0af69e3ce6 to your computer and use it in GitHub Desktop.
ucfirst(); lcfirst(); ucwords(); in typescript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment