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

106
Views
Can I remove duplicates AFTER MAPPING my object array?

I have an Object called data contains list of arrays. I just map my data to get a specific column data as follows.

 const DisplayData = data
    ?.filter((vendors) => vendors?.vendors != null)
    .map((risk) => {
      return (
        <tr>
          <td
            className="link_hover"
            onClick={() => {
              dispatch(vendors(risk.vendors));
            }}
          >
            <Link
              className=" link_hover text-decoration-none second-color  vendor_list_font_size"
              to="/vendor_critical_details"
            >
              {risk.vendors}
            </Link>
          </td>
        </tr>
      );
    });

From the above code I got list of ``vendor` names. but I got duplicate names. Is there any trick to remove duplicates from the result?

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Reduce instead of filter

const vendorList = data
?.reduce((acc,vendors) => {
  const vendor = vendors?.vendors ?? null
  if (vendor != null && !acc.includes(vendor)) acc.push(vendor)
  return acc
},[]);
const DisplayData = vendorList.length === 0 ? "" : vendorList.map(risk => ...
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!