I have multiple layers of objects nested within a main object like this:
var initialObj = {
firstKey: {
x: true,
y: 5
},
secondKey: {
x: false,
y: 10
},
thirdKey: {
x: true,
y: 15
}
}
My goal is to extract an array of objects based on certain conditions within the nested objects. This array will also include the corresponding keys in a [key,value]
format, similar to this:
resultingArray = [
{
x: true,
y: 5,
z: "firstKey"
},
{
x: true,
y: 15,
z: "thirdKey"
}
]