DEV Community

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

Posted on

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).