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

135
Views
How to grouped json and sum its score?

How to grouped json and sum its score? i have make this approach but still stuck to addition the value.

I have this json value:

A = [ { name: 'Boy', score: 10}, { name: 'Marry', score: 90 }, { name: 'Boy', score: 70 } ]

i want to get the result json like this

Result = [ { name: 'Boy', score: 80 }, { name: 'Marry', score: 90 } ]

i tried this code but still failed to add the value

let grouped = Object.values(data.reduce((r, {nickname, score}) => {
                r[nickname] = r[nickname] || { nickname, score: [] };
                r[nickname].score =  r[nickname].score + score
                return r;
            }, {}))

            console.log(grouped);

the result is

Result = [ { name: 'Boy', score: '1070' }, { name: 'Marry', score: '90' } ]

it converted to string :( Please help me

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!