Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda