📅  最后修改于: 2023-12-03 15:29:40.009000             🧑  作者: Mango
Welcome to the "Break CamelCase" Codewars challenge!
In programming, camelCase is a naming convention where multiple words are combined to form a single word by capitalizing the first letter of each word except for the first word. For example, breakCamelCase
would be a camelCase word.
Your challenge is to write a function that takes in a camelCase word and returns a string with a space before each capitalized letter.
Here is an example JavaScript code snippet for the function:
function solution(string) {
return string.replace(/([A-Z])/g, " $1");
}
This function uses a regular expression to find all capitalized letters in the word and replaces them with a space and the capitalized letter.
Here are some examples of the function in action:
solution("breakCamelCase"); // Returns "break Camel Case"
solution("helloWorld"); // Returns "hello World"
Congratulations on completing the "Break CamelCase" Codewars challenge! We hope that you have gained some valuable insights into JavaScript programming and regular expressions. Keep up the good work!