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

122
Views
how to for loop object in javascript

I want to loop through req.body payload object in a nodejs application and get the array object with SplitType = 'FLAT'. So after I finish looping through the array object I'll push the value into an empty array. I'm getting an error saying the SplitType is not defined. below is the object array that I want to loop through.

{
"ID": 13092,
"Amount": 4500,
"Currency": "NGN",
"CustomerEmail": "anon8@customers.io",
"SplitInfo": [
    {
        "SplitType": "FLAT",
        "SplitValue": 450,
        "SplitEntityId": "LNPYACC0019"
    },
    {
        "SplitType": "RATIO",
        "SplitValue": 3,
        "SplitEntityId": "LNPYACC0011"
    },
    {
        "SplitType": "PERCENTAGE",
        "SplitValue": 3,
        "SplitEntityId": "LNPYACC0015"
    },
    {
        "SplitType": "RATIO",
        "SplitValue": 2,
        "SplitEntityId": "LNPYACC0016"
    },
    {
        "SplitType": "FLAT",
        "SplitValue": 2450,
        "SplitEntityId": "LNPYACC0029"
    },
    {
        "SplitType": "PERCENTAGE",
        "SplitValue": 10,
        "SplitEntityId": "LNPYACC0215"
    },
]

}

Here is the for loop code

for (let i = 0; i = splitInfo.length; i++) {
    if(splitInfo[i].SplitType === 'FLAT') {
      result.initialBalance = flat(initialBalance, splitInfo.SplitValue);
      result.SplitBreakdown.push({
        SplitEntityId: splitInfo.SplitEntityId,
        Amount: splitInfo.SplitValue
      });
    }
  }
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Your loop is wrong, I think you mean:

for (let i = 0; i < splitInfo.length; i++) {
about 4 years ago · Santiago Gelvez 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!