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

158
Vistas
Javascript - Sorting an array of objects based on another array

I have two arrays. They look like this but are longer in my code.

let arrayA = [{heading: "heading2", body: "text body2"}, {heading: "heading", body: "text body"}, {heading: "heading4", body: "text body4"}, {heading: "heading3", body: "text body3"}]
let arrayB = ["heading", "heading2", "heading 3", "heading 4"]

My html page needs to loop over arrayA and for each item return

<h1>item.heading</h1>
<p>item.body</p>

How would i go about sorting arrayA to get the same order as arrayB ?

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