Problema
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.
Vincoli
0 ≤ length of text ≤ 10,000
Esempi
Esempio 1
Input:
text = "Hello World"
Output atteso:
expected = "hello-world"
Input:
std::string text = "Hello World";
Output atteso:
std::string expected = "hello-world";
Input:
string text = "Hello World";
Output atteso:
string expected = "hello-world";
Spiegazione
The space becomes a dash and letters are lowercased: "hello-world".
Esempio 2
Input:
text = "Learn To Code"
Output atteso:
expected = "learn--to-code"
Input:
std::string text = "Learn To Code";
Output atteso:
std::string expected = "learn--to-code";
Input:
string text = "Learn To Code";
Output atteso:
string expected = "learn--to-code";
Spiegazione
Each space becomes its own dash: "learn--to-code".
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.