Write a function flattenObject(obj) that flattens a deeply nested object into a single-level object, using dot notation for nested keys.javascriptCopy
Difficulty: 3/10object traversal, recursion, string manipulationjavascriptCopyScenario Questions0-2 years experience1We have a small configuration object that may contain nested sections. How would you write a function to flatten it so that nested keys are joined with dots?2Given the object { a: { b: 1 }, c: 2 }, walk me through what your flattenObject would return and why.