The case
function takes a string and a type as parameters, and returns a modified version of the string based on the specified type. The type parameter is mandatory and must be one of the following values:
upper
: converts the string to uppercaselower
: converts the string to lowercasecapitalize
: capitalizes the first letter of the string
Parameters
string
: the string to be modifiedtype
: the type of modification to be applied to the string. Must be one ofupper
,lower
, orcapitalize
.
Examples
case("hello", type="upper")
returns: "HELLO"
case("HELLO", type="lower")
returns: "hello"
case("hELLO", type="capitalize")
returns: "Hello"