DEV Community

Qroia FAK(C)E
Qroia FAK(C)E

Posted on

3 2

Codewars Challenge Day2: Break camelCase

Name Kata: Break camelCase / 6kuy

Details

Complete the solution so that the function will break up camel casing, using a space between words.

Example

'camelCase' -> 'camel Case'

My Solutions

JavaScript

const solution = (str) => {
return str.split(/\s+|\_+|(?=[A-Z])/gm).join(' ')
}

Python

def solution(string: str) -> str:
res = ''
for symbol in string:
if symbol.upper() == symbol:
res = res + ' ' + symbol
else:
res = res + symbol
return res

Top comments (1)

Collapse
 
xzayedx profile image
xZAYEDx

I was a bit confused with this challenge on Codewars, could you please explain how did you come with the solution with just 2 lines of code (JS).

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay