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

189
Vistas
how to remove same elements from array and add count to other objects javascript?

I have 1 object (it came from localstroage). But there are some dublicates. how can i remove it from easy way?

"mainchart" is my array object.

function check() {
  for (let i1 = 0; i1 < mainchart.length; i1++) {
    for (let i2 = 0; i2 < mainchart.length; i2++) {  
      if (mainchart[i1].id === mainchart[i2].id) {
        console.log(mainchart[i1] , mainchart[i2]);
      }
    }
  }
}

check();
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

An easy way to remove duplicate values from an array is converting the array in to a set (collection of unique values), putting the values of the set in a new array:

let array1 = ["a", "b", true, 3, 67, true, "a"];

let array2 = [...new Set(array1)];

console.log(array2); // [ 'a', 'b', true, 3, 67 ]

Hope it can help you 🦄

about 4 years ago · Juan Pablo Isaza Denunciar
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