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

114
Views
How can i extract and concatenate specific values from an array, and then generate a new array based on that selection ? Javascript

guys,

I want to learn a more complex usage of methods, array's and objects. For exemple i have this dummy array:

const userArr = [
  {
    name: 'john doe',
    sales: 9500,
    projects: 2,
  },
  {
    name: 'john doe',
    sales: 5500,
    projects: 1,
  },
  {
    name: 'max payne',
    sales: 7500,
    projects: 2,
  },
  {
    name: 'max payne',
    sales: 25000,
    projects: 2,
  },
];

And i want to sum up all the sales and projects for each user and add that in to a new array. The result should look like this:

const uniqueUserValues = [
  {
    name: 'john doe',
    sales: 15000,
    projects: 3,
  },
  {
    name: 'max payne',
    sales: 32500,
    projects: 4,
  },
];

I have some attemps with reduce method but no success. I can't get the logic of it. I would greatly appreciate a solution.

Thanks!

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