I need to create one object from array of objects with a a common key present in the objects.
Input
let data = [
{ code: "name", type: "text", value: "abc" },
{ code: "email", type: "email", value: "[email protected]" },
{ code: "username", type: "text", value: "xyz" },
];
Expected output
{
email: { code: "email" },
name: { code: "name" },
username: { code: "username" },
}
I can iterate through the array using map function and manually create the object. But there should be an easy way of doing it.