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

179
Visualizações
How can I create a function that will remove the duplicate number but also the actual number? input [1,2,2,3,3,4] output should be [1,4]

I want to remove all the duplicate numbers and the function will return a unique number that has no duplicate number. Suppose I have this array [1,2,2,3,3,4] I want to return [1,4] because 1,4 doesn't have duplicate numbers.

This is my code and the problem is I am getting duplicate numbers too. The Input of this function is [6, 1, 2, 3, 1, 2, 2, 3] and the output should be [6]

Can anyone help me with how can I solve my problem?

function deleteProducts(ids, m) {
  // Write your code here
  var uniqueArray = [];

  // Loop through array values
  for (i = 0; i < ids.length; i++) {
    if (uniqueArray.indexOf(ids[i]) === -1) {
      uniqueArray.push(ids[i]);
    }
  }
  return uniqueArray;

}

deleteProducts([6, 1, 2, 3, 1, 2, 2, 3]) // output [6, 1, 2, 3]
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