there is the following array:
const fData = [
{ownerName: "a", type: "1", total: 85}
{ownerName: "a", type: "2", total: 22}
{ownerName: "b", type: "1", total: 11}
{ownerName: "b", type: "2", total: 11}
{ownerName: "c", type: "1", total: 121}
{ownerName: "c", type: "2", total: 11}
]
want to reconstitute the following array:
[{ownerName: "a", "1": 85, "2": 22}
{ownerName: "b", "1": 11, "2": 11}
{ownerName: "c", "1": 121, "2": 11}
I am currently working on the following code:
let newName = map(uniq(ownerName), (item) => {
return {
ownerName: item,
};
});
let newType = map(uniq(type), (item) => {
return {
type: item,
};
});
where uniq and map are libraries of referenced third-party lodash.
I don"t know how to write it down. For guidance, thank you