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

101
Views
How to check if objects have same properties and then put a total count

I need some help because I'm stuck. If somebody can put me in right direction. the testArr is a much bigger file. But the simple explenation is that I need find the same period and have matching application and based on that have a total count on all payslipCount.

so if I'm searching för a period like '202103' in a date picker. I need to see total paySlipCount for that period and that application. like

     period: 202103 
     pay: Pay100
     amount: total amount
testArr = [
    {application: "PAY100",
    payslipCount: 22,
    period: "202101",
    },
    
    {application: "PAY100",
    payslipCount: 12,
    period: "202101",
    },
    
    {application: "PAY600",
    payslipCount: 0,
    period: "202101",
    },
    
    {application: "PAY600",
    payslipCount: 44,
    period: "202101",
    },
    
    {application: "PAY600",
    payslipCount: 23,
    period: "202103",
    },
    
    {application: "PAY600",
    payslipCount: 44,
    period: "202103",
    },];

I just need somebody to push I in right direction.

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

0

Something like this should do the work. You can replace the date with a variable from the form.

testArr.filter(o => o.period == '202101')
       .map(item => item.payslipCount)
       .reduce((prev, next) => prev + next)
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!