Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
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 Respuestas
Responde la pregunta

0

Your loop is wrong, I think you mean:

for (let i = 0; i < splitInfo.length; i++) {
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda