toKebabCase
Converts a string to kebab-case format (lowercase and words separated by hyphens).
Syntax
typescript
toKebabCase(str: string): stringParameters
| Parameter | Type | Description |
|---|---|---|
str | string | The input string. |
Returns
| Type | Description |
|---|---|
string | The string converted to kebab-case. |
Example
typescript
toKebabCase("Exemplo de String"); // "exemplo-de-string"
toKebabCase(" Teste Kebab Case "); // "teste-kebab-case"
toKebabCase(""); // ""Notes
- Throws
TypeErrorif the argument is not a string. - Extra spaces are removed before conversion.
