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

184
Views
Best way to restructure my Duplication Removal function

So I have a VueJS table, and sometimes I push double values to this table, I've created the following to remove the doubles before they get pushed onto the table, but I feel I've gone about it wrong, my data does not flow and it's probably too long. Perhaps the filterin should happen right after I declare my Consts? I'd be happy to hear suggestions and examples on how best this can be achieved in my JS.

methods: {
tableDataToDataValueCells(participant) {
  const fields = [
    { fieldName: 'companyNames', fieldClass: 'CompanyName' },
    { fieldName: 'aliases', fieldClass: 'Alias' },
    { fieldName: 'addresses', fieldClass: 'Address' },
    { fieldName: 'phones', fieldClass: 'Phone' },
    { fieldName: 'emails', fieldClass: 'Email' },
    { fieldName: 'birthdates', fieldClass: 'Birthdate' },
    { fieldName: 'customerNumbers', fieldClass: 'CustomerNumber' },
    { fieldName: 'ibans', fieldClass: 'BankAccount' },
  ];
  let result = [];
  

  fields.forEach(field => {
    if (participant[field.fieldName].length > 0) {
      result.push({
        attributeName: field.fieldName,
        columnName: I18n.t(`ccenter.participant.table.${snakeCase(field.fieldName)}`),
        columnValues: participant[field.fieldName],
        fieldClass: field.fieldClass,
      })
    }
  });
  // return result;

  // filter out duplicates here
  let array = result;
  let unique = [];
    data.forEach(element => {
      if (!unique.includes(element)) {
        unique.push(element)
      }
    });
    return array;
    }
  }
};
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!