-
-
Save feload/92e2fc393273d453f4a07a3a9c4b3058 to your computer and use it in GitHub Desktop.
Formats a string into a paragraph string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const p = (str = "") => { | |
if(!str || str.length < 1) return ""; | |
str = str.replace('_', ' '); | |
return str.split(" ").map((word, index) => { | |
if(index == 0) { | |
const wordChunks = word.toLocaleLowerCase().split(''); | |
wordChunks[0] = wordChunks[0].toUpperCase(); | |
return wordChunks.join(''); | |
}else{ | |
return word.toLowerCase(); | |
} | |
}).join(' '); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment