invertCase
Inverts the case of each character in a string: uppercase becomes lowercase and vice versa.
Syntax
typescript
invertCase(str: string): stringParameters
| Parameter | Type | Description |
|---|---|---|
str | string | The string to be processed. |
Returns
| Type | Description |
|---|---|
string | A new string with the case of each character inverted. |
Example
typescript
invertCase("AbC"); // "aBc"
invertCase("Olá MUNDO!"); // "oLÁ mundo!"
invertCase(""); // ""Notes
- Throws
TypeErrorif the argument is not a string. - Non-alphabetic characters remain unchanged.
