Question: Need to make a function that returns all properties added to the top level of the object USING JAVASCRIPT. These only include properties which have
Need to make a function that returns all properties added to the top level of the object USING JAVASCRIPT. These only include properties which have a primitive type.
The end result in this case should be: { x: 1, z: 2, m: 1, p: 1 }

const obj2 = { X: 1, y: { Z: 2, -k:{ m: 1, n: ( p: 1 }; console.log(obj2.flatten()); // { x: 1, Z: 2, m: 1, p: 1 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
