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

250
Views
Updating the value in array based on condition in javascript

I would like to add/append value filtering based on unique dates and append the value inside latitude value which is inside another object coordinates.

Input:

data = [
  {
    latitude: "1.2",
    longitude: "2.2",
    address: "sadsdasd",
    time_stamp: "04 June 2022 11.23 am"
  },
  {
    latitude: "1.5",
    longitude: "2.5",
    address: "sadsdasd",
    time_stamp: "04 June 2022 11.55 am"
  },
  {
    latitude: "1.7",
    longitude: "2.7",
    address: "sadsdasd",
    time_stamp: "05 June 2022 11.57 am"
  },
  {
    latitude: "1.8",
    longitude: "2.8",
    address: "sadsdasd",
    time_stamp: "05 June 2022 11.58 am"
  },
  {
    latitude: "1.9",
    longitude: "2.9",
    address: "sadsdasd",
    time_stamp: "06 June 2022 11.59 am"
  }
]

Output:

[
  {
    "date": "04-06-2022",
    "coordinates": [{
      "latitude": "1.2",
      "longitude": "2.2"
    },
    {
      "latitude": "1.5",
      "longitude": "2.5"
    }
    ]
  },
  {
    "date": "05-06-2022",
    "coordinates": [{
      "latitude": "1.7",
      "longitude": "2.7"
    },
    {
      "latitude": "1.8",
      "longitude": "2.8"
    }
    ]
  }, {
    "date": "06-06-2022",
    "coordinates": [{
      "latitude": "1.9",
      "longitude": "2.9"
    }]
  }
]

It should filter based on condition and append the value.

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!