Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!