Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda