Loading problem…
Convert a flat object with dot-separated paths into a nested object.
Implement:
function unflattenObject(flatObj) {}
Behavior:
{"a.b": 1}
{ a: { b: 1 } }
{}
unflattenObject({ 'user.name': 'Sam', 'user.age': 20, }); // { user: { name: 'Sam', age: 20 } } unflattenObject({ a: 1, 'config.theme.color': 'blue', }); // { a: 1, config: { theme: { color: 'blue' } } }
2 hints available with Pro