re: Daily Challenge #95 - CamelCase Method VIEW POST


Replace to the rescue!

const camelCase = str => str.replace(/\s([a-z])/g, (_, x) => x.toUpperCase())

Doesn't match the first word, should be /(?:^|\s)([a-z])/g for that or something.


I don't capitalise the first word of a camelCase construct. As far as I'm aware, it isn't customary in JavaScript.

But you are right, if one were to capitalise the first word as well, the regular expression would have to be modified accordingly.

The confusion is because the description says camelCase but they mean PascalCase.

code of conduct - report abuse