SnackCase To Normal
This SnakeCase to Normal
Function is used for
converting snake_case to Normal Format.
Function
snakeToNormal.ts
export function capitalize(word: string){
return word && word[0].toUpperCase() + word.slice(1).toLocaleLowerCase();
}
export function SnakeCaseToNormal(v: string){
return capitalize(v.split("_").join(" ").toLocaleLowerCase());
}
Usage
index.tsx
const Info = () => {
const text = "lorem_ispum";
return (
<div>
<h1>{text && SnakeCaseToNormal(text)}</h1>
</div>
)
}
Output
'Lorem ispum'