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

103
Vistas
How do i access the mapped Array in JavaScript?

probably a really easy question for the intermediate and experienced programmer, but to me it is quite troubling:

I saw this code on a question here: (I am not sure if i am allowed to give the link but i the headline is:

Sort a numeric array inside of an object of arrays while keeping the order of the other arrays in the same order as the sorted numeric array)

const facilities = ["MD01", "PA01", "OH01", "NC01", "GA01", "SC01", "SC02", "TN01", "AL01", "FL02", "TX01", "IN01", "SC03", "FL01"];
    const distances = [133, 32, 538, 422, 795, 666, 664, 822, 1118, 867, 1504, 657, 635, 1210];
    const times = ["2 hours 12 mins", "47 mins", "8 hours 20 mins", "6 hours 32 mins", "12 hours 0 mins", "10 hours 2 mins",
        "9 hours 56 mins", "12 hours 21 mins", "16 hours 33 mins", "12 hours 43 mins", "22 hours 16 mins", "10 hours 16 mins",
        "9 hours 39 mins", "17 hours 35 mins"
    ];
    
const combined = facilities.map((facility,i) =>({facility, distance: distances[i], time: times[i]}))
                .sort((a,b) => a.distance-b.distance)
 
console.log(combined)
    

while the code did the indeed give me an array of objects, i am now confused about how to access them. I have read somewhere that i can only access them within the callback function. On the other hand, i can console.log(combined).

I thought something along the lines would work, but nothing did:

console.log(combined.distances);
console.log(combined[0].distances);
console.log(combined[0].distances[0]);
console.log(combined[0].distance[0]);

And so on. I would have asked in comment on the thread, but since my score is too low and i am not confident in answering questions, i can only open a new one.

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