I have the object as below:
const givenData = {
"ProcessA": { "state": "on", "used": "16.41" },
"ProcessB": { "state": "off", "used": "16.40" },
"ProcessC": { "state": "off", "used": "16.36" },
"ProcessD": { "state": "on", "used": "16.45" }
};
And I want my output as below two different objects:
let ob1= {
"ProcessA":"on",
"ProcessB":"off",
"ProcessC":"off",
"ProcessD":"on",
}
let obj2={
"ProcessA":"16.41",
"ProcessB":"16.40",
"ProcessC":"16.36",
"ProcessD":"16.45",
}
can anyone suggest me if there is any easy solution for this?
for...in...would be enough (if you know the names of the properties)Object.entries()andArray.map()