From an array of objects consisting of customer details, I would like to form a new array of arrays of objects grouped by the same name and email. That is, the new array will contain arrays of objects with the same name and email along with it’s other individual original details.
const originalArray = [
{ _id:"23d3",name:"John doe", email:"[email protected]",...},
{ _id:"ww04",name:"lukas martin", email:"[email protected]",...},
{ _id:"55d3",name:"John doe", email:"[email protected]",...},
{ _id:"2e05",name:"lukas martin", email:"[email protected]",...},
{ _id:"33d3",name:"John doe", email:"[email protected]",...},
{ _id:"602i",name:"Terry lens", email:"[email protected]",...}]
After sorting through the array by name and email, it should look like this ????
const expectedResult = [
[{ _id:"23d3",name:"John doe", email:"[email protected]",...},
{ _id:"55d3",name:"John doe", email:"[email protected]",...}],
[{ _id:"ww04",name:"lukas martin", email:"[email protected]",...},
{ _id:"2e05",name:"lukas martin", email:"[email protected]",...}],
[{ _id:"33d3",name:"John doe", email:"[email protected]",...}],
[{ _id:"602i",name:"Terry lens", email:"[email protected]",...}]
]
Thank you very much.
New contributor
queen.dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.