Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Get all objects in an array for same property value from an array of data

data Array

let data = [
{name: "ABC", email: "abc@gamil.com"},
{name: "xyz", email: "xyz@gamil.com"}, 
{name: "different name", email: "abc@gamil.com"}, 
{name: "xyz", email: "cde@gamil.com"}
]

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:

[{
"abc@gmail.com": [
{name: "ABC", email: "abc@gamil.com"},
{name: "different name", email: "abc@gamil.com"}]
},
{"xyz@gamil.com": [
{name: "xyz", email: "xyz@gamil.com"}]
},
{"cde@gamil.com": [
{name: "xyz", email: "cde@gamil.com"}]
}
]

Objective is to get all the duplicate data on the base of email from the available data.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const data = [
  { name: 'ABC', email: 'abc@gamil.com' },
  { name: 'xyz', email: 'xyz@gamil.com' },
  { name: 'different name', email: 'abc@gamil.com' },
  { name: 'xyz', email: 'cde@gamil.com' },
];
const result = data.reduce((acc, curr) => {
  const key = curr.email;
  if (acc[key]) {
    acc[key].push(curr);
  } else {
    acc[key] = [curr];
  }
  return acc;
}
  , {});
console.log(result);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda