Programming Exercises

Create a component that takes a hardcoded JSON object and flattens it into a single-level object.

Hard

Problem Statement

Create a component that takes a hardcoded JSON object and flattens it into a single-level object.

Sample Input

{ "a": 1, "b": { "c": 2, "d": { "e": 3 } } }

Sample Output

Flattened Object: { "a": 1, "b.c": 2, "b.d.e": 3 }

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React from "react"; const FlattenObject = () => { return ( <div> {/* Display the flattened object */} </div> ); }; export default FlattenObject;
Log in or sign up to run or submit your code.Log inSign up
Input
{ "a": 1, "b": { "c": 2, "d": { "e": 3 } } }
Expected Output
Flattened Object: { "a": 1, "b.c": 2, "b.d.e": 3 }