JS Built-ins
TypeScriptintermediate

Advanced β€” toCamelCase

πŸ“– Usage Example
toCamelCase('hello_world')   // β†’ 'helloWorld'
toCamelCase('foo_bar_baz')   // β†’ 'fooBarBaz'

toCamelCase converts snake_case strings to camelCase by capitalizing letters after underscores.

Advanced: String Transformation β€” camelCase

Challenge: Implement toCamelCase(str: string): string converting a snake_case or kebab-case string to camelCase.

toCamelCase('hello_world')    // β†’ 'helloWorld'
toCamelCase('foo-bar-baz')    // β†’ 'fooBarBaz'
πŸ’‘ Hints (1)
  • β€’ A regex replacing [-_] followed by a char, capitalizing that char, works cleanly.