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

55
Views
React combine two queries

What I want is to mixed the geoCode of location and people, how can I achieve that?

const calculate = (location, people) => {
   let geoCode = {}
    const peoples = people.map((people) = {
         return {
             geoCode: {
               latitude: a.geoCode.latitude,
               longitude: a.geoCode.longitude,
             }
         }
         return { //this is for location
             geoCode: {
               latitude: location[0].address.geoCode.latitude,
               longitude: location[0].address.geoCode.longitude,
             }
         }

     console.log(peoples)
   }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You cannot return two objects from a map. You should merge the properties of location and people into a single object and then return that object. From your code I am assuming that both people and location have geocode.

const people = [{
    name: "People1",
    latitude: 111,
    longitude: 111,
  },
  {
    name: "People2",
    latitude: 222,
    longitude: 222,
  },
  {
    name: "People3",
    latitude: 333,
    longitude: 333,
  },
];

const loc = [{
  address: {
    geoCode: {
      latitude: 123,
      longitude: 345,
    }
  }
}];

const calculate = (location, people) => {
  let geoCode = {}
  const peoples = people.map((item) => {
    return {
      ...item,
      geoCode: {
        latitude: location[0].address.geoCode.latitude,
        longitude: location[0].address.geoCode.longitude,
      }
    };
  });

  console.log(peoples);
}

const res = calculate(loc, people);

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