data Array
let data = [
{name: "ABC", email: "[email protected]"},
{name: "xyz", email: "[email protected]"},
{name: "different name", email: "[email protected]"},
{name: "xyz", email: "[email protected]"}
]
I need result where all objects from an array having same email gets combined into one array as an value and key should be the email. for example the answer of above email should be:
[{
"[email protected]": [
{name: "ABC", email: "[email protected]"},
{name: "different name", email: "[email protected]"}]
},
{"[email protected]": [
{name: "xyz", email: "[email protected]"}]
},
{"[email protected]": [
{name: "xyz", email: "[email protected]"}]
}
]
Objective is to get all the duplicate data on the base of email from the available data.