In programming, there are five common cases: camelCase, snakecase, kebab-case, PascalCase and UPPER_CASE_SNAKE_CASE. For this project, you are to Write a function that takes in a sentence and a desired case as the inputs, and then converts the sentence into the desired case.
// Examples:
convert("Hello, World.", "camel")
// Output:
helloWorld
convert("Hello, World.", "snake")
// Output:
hello_world
convert("Hello, World.", "kebab")
// Output:
hello-world
convert("Hello, World.", "pascal")
// Output:
HelloWorld
convert("Hello, World.", "uppercasesnake")
// Output:
HELLO_WORLD![]() |
Guide to Swift Strings |
|---|
