Problem, as an interviewer would state it:
"Write snakeToCamel(obj) and camelToSnake(obj) — recursively convert every object key between snake_case and camelCase, correctly handling nested objects and arrays of objects."
Examples:
snakeToCamel({ user_id: 1, address_info: { zip_code: "10001" } });
// { userId: 1, addressInfo: { zipCode: "10001" } }
Clarifying questions expected:
- Should this recurse into arrays too, converting keys of objects INSIDE an array value?
- What about keys that are already in the target case, or contain numbers?
- Should Date objects or other non-plain-object values be recursed into, or left alone?
Code / implementation expected: Yes — real, direct proof on a genuinely nested structure (object + array of objects), including a full round-trip back to the original.