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

256
Vistas
How to combine list of dictionaries in Javascript into a nested dictionary?

I am new to Javascript and I have question very similar to How to combine multiple dictionaries in Javascript?

Except that I want to achieve a nested dictionary.

var dictA = {gender: 'male', age_group: 'young', favourite_band: 'Metallica', number_of_visits: 42};
var dictB = {gender: 'female', age_group: 'old', favourite_band: 'Beatles', number_of_visits: 2};
var dictC = {gender: 'male', age_group: 'young', favourite_band: 'Foo Fighters', number_of_visits: 1};
var dictD = {gender: 'male', age_group: 'old', favourite_band: 'Rolling Stones', number_of_visits: 12};

Expected Outcome:

var result = 
   {
     'male': {
              'young': {'Metallica': 42, 'Foo Fighters': 1},
              'old': {'Rolling Stones': 12}
             },
     'female': {'old': {'Beatles': 2}}

   }

Possibly there is even one more nested information. Is this somehow achieveable? I appreciate every help!

Edit: that example is only showing how it’s done for one „layer“. How can I for example provide a list of „layer columns“ and achieve what’s done above?

about 4 years ago · Juan Pablo Isaza
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