Browse Source

docs(camelToSnakeCase) : rewrite the description

Fix the output
DEV-4017-prototypes-exercise-1-animals
Hamza elkhatri 2 years ago committed by José Rosendo
parent
commit
88ff699bc1
  1. 21
      subjects/cameltosnakecase/README.md

21
subjects/cameltosnakecase/README.md

@ -1,9 +1,19 @@
## Camel-to-snake-case
### Instructions
Write a function that converts a string from `camelCase` to `snake_case`.
Lower camel case is the practice of writing phrases without spaces or punctuation, it indicates the separation of one word or more with a single capitalized letter between each word except the first one. Snake case is a style of writing in which each space is replaced by an underscore (_) character.
For this exercise you need to know that camelCase has two different writing alternatives that will be accepted:
- lowerCamelCase
- UpperCamelCase
Some rules for writing in camelCase:
- The word does not end on a capitalized letter (CamelCasE).
- No two capitalized letters shall follow directly each other (CamelCAse).
- Numbers or punctuation are not allowed in the word anywhere (camelCase1).
Here are some rules for you to follow:
@ -11,11 +21,6 @@ Here are some rules for you to follow:
- If the string is not `camelCase`, return the string unchanged.
- If the string is `camelCase`, return the `snake_case` version of the string.
Basic `lowerCamelCase` Capitalization Rules:
- The first letter should be lower case.
- No numbers or punctuations are allowed in the word at any place (camelCase1).
### Expected function
@ -38,6 +43,7 @@ func main() {
fmt.Println(CamelToSnakeCase("HelloWorld"))
fmt.Println(CamelToSnakeCase("helloWorld"))
fmt.Println(CamelToSnakeCase("camelCase"))
fmt.Println(CamelToSnakeCase("CAMELtoSnackCASE"))
fmt.Println(CamelToSnakeCase("camelToSnakeCase"))
fmt.Println(CamelToSnakeCase("132322"))
}
@ -47,9 +53,10 @@ and the output should be:
```console
$ go run .
HelloWorld
Hello_World
hello_World
camel_Case
CAMELtoSnackCASE
camel_To_Snake_Case
132322
```

Loading…
Cancel
Save