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

187
Views
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 answers
Answer question

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 Report
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!