FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Medium

Camel Case Keys

25mins

Write a function camelCaseKeys(obj) that takes an object and returns a new object where all keys are converted to camelCase.

The function should:

  • Recursively convert keys of nested objects and arrays.
  • Leave non-object values unchanged.
  • Ensure the returned object has the same values as the original, but with transformed keys.

Example

camelCaseKeys({ "first_name": "John", "last-name": "Doe", "address_info": { "zip_code": 12345 } }); // { firstName: "John", lastName: "Doe", addressInfo: { zipCode: 12345 } }

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests