From 88ff699bc14a9a62ebd0c11e35280a8d580eccec Mon Sep 17 00:00:00 2001 From: Hamza elkhatri <40549481+Hamzaelkhatri@users.noreply.github.com> Date: Fri, 5 Aug 2022 19:53:51 +0100 Subject: [PATCH] docs(camelToSnakeCase) : rewrite the description Fix the output --- subjects/cameltosnakecase/README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/subjects/cameltosnakecase/README.md b/subjects/cameltosnakecase/README.md index 8e0edfca..6ed5bb8a 100644 --- a/subjects/cameltosnakecase/README.md +++ b/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 ```