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

180
Vistas
Why is returning only one object in for in loop

I'm making an app in react and I don't know why when I'm using for-in loop that returns only the first object, not all of them. My expected output is like in arr.map() but unfortunately I'm not able to that using objects instead of arrays.

places: {
  place_1: {
    title: 'Place 1',
  },
  place_2: {
    title: 'Place 2',
  },
  place_3: {
    title: 'Place 3',
  },
}


const App = () => {

 const handleMenu = () => {
    for (const key in places) {
      if (Object.hasOwnProperty.call(places, key)) {
        return (
          <h1>
            title={places[key].title}
          </h1>
        );
      }
    }
  };

  return (
    <div>
      {handleMenu()}
    </div>
  )
}

export default App

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