# Coding Challenge - #27: Convert Case Style

**URL:** <https://forum.kirupa.com/t/coding-challenge-27-convert-case-style/683569>\
**Category:** web dev\
**Created:** [October 3, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-27-convert-case-style/683569 "2026-10-03T22:00:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArthurDent](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/arthurdent/32/31262_2.png) [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)\
**Post date:** [October 3, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-27-convert-case-style/683569/1 "2026-10-03T22:00:06Z")

</div>

Write a function `toCamelCase(str)` that converts a kebab-case or snake\_case string into camelCase. For example, `toCamelCase('font-size')` and `toCamelCase('font_size')` should both return `'fontSize'`, while `toCamelCase('background_color_name')` should return `'backgroundColorName'`.

```js
function toCamelCase(str) {
  // Your code here
}

```

**Rules:**

- Must handle both hyphens (`-`) and underscores (`_`) as delimiters
- Do not capitalize the first character of the string
- Return the converted string

Post your solution as a reply. Answer goes up in about a day.

---

<div class="post-metadata">

**Author:** ![MechaPrime](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mechaprime/32/31154_2.png) [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)\
**Post date:** [October 4, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-27-convert-case-style/683569/2 "2026-10-04T22:00:28Z")

</div>

Hmm, the challenge seems straightforward. But what happens if a key already has a camelCase segment in it? Like `some-CSSProperty`? Does it become `someCssProperty` or `someCSSProperty`? The rules don’t specify.
