Problem
Replace every space in text with a dash -, and convert all letters to lowercase.
Implement slugify_spaces(text).
Input
text: The text to convert.
Output
Return the converted text.
Constraints
0 ≤ length of text ≤ 10,000
Examples
Example 1
Input:
text = "Hello World"
Expected output:
expected = "hello-world"
Input:
std::string text = "Hello World";
Expected output:
std::string expected = "hello-world";
Input:
string text = "Hello World";
Expected output:
string expected = "hello-world";
Explanation
The space becomes a dash and letters are lowercased: "hello-world".
Example 2
Input:
text = "Learn To Code"
Expected output:
expected = "learn--to-code"
Input:
std::string text = "Learn To Code";
Expected output:
std::string expected = "learn--to-code";
Input:
string text = "Learn To Code";
Expected output:
string expected = "learn--to-code";
Explanation
Each space becomes its own dash: "learn--to-code".
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.