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