Can someone assist me with transforming the array structure in logicData
to the format of object in returnObject
?
I am looking for a function that can take the logicData
array and return an object in the format specified below.
Furthermore, I also need to be able to recreate the original logicData
array using the returned object. Any help would be greatly appreciated. Thank you!
// array
var logicData = [
{
details: {
name: "User-1",
id: 1,
age: "38",
},
company: "XYX",
position: "Accountant",
},
{
details: {
name: "User-2",
id: 2,
age: "55",
},
company: "XYX",
position: "Sales executive",
},
// additional objects omitted for brevity
]
Desired object format:
// required object format
const returnObject = {
first: {
details: {
name: "User-1",
id: "1",
age: "38",
},
company: "XYX",
position: "Accountant",
},
second: {
first: {
details: {
name: "User-2",
id: 2,
age: "55",
},
company: "XYX",
position: "Sales executive",
},
// additional nested objects omitted for brevity
}
}