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

213
Views
FInd duplicates on output

I submit some data via AJAX post and when I get receive response I output it via a loop.

$.each(data, function() {
    $("#em").append('<i class="bi bi-pin-map-fill'+(lat == this.lat && lon == this.lon ? " bg-danger" : "")+'"></i> '+this.lat+' '+this.lon);

    let lat = this.lat,
        lon = this.lon;
}

In some case the coordinates I receive could be of the exact same location, so I'd like to be able to mark those duplicates by adding background color. So I've added a condition to check for matches but am blanking how to implement it, since I can't really set the vars at the end of my loop... Need some nudge in the right direction.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I understand correctly what you are trying to do, you could declare a coordinate array before your loop, then in the loop test if the current coordinate is already in the array with includes method.

For example:

const coordArray = [];
$.each(data, function() {
   const isCoordDupli = coordArray.includes(`${this.lat} ${this.long}`);
   $("#em").append('<i class="bi bi-pin-map-fill'+(isCoordDupli ? " bg-danger" : "")+'"></i> '+this.lat+' '+this.lon);

   coordArray.push(`${this.lat} ${this.long}`);
});
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!