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

178
Vistas
innerhtml not print full array

I'm using innerhtmal for output but the problem is it shows 1 less value the array I cant find the problem.

enter image description here

enter image description here

await fetch(urlbody, bodyrequestOptions)
  .then((response) => response.json())
  .then((payload) => {
      console.log(payload)

      payload.map(({
        TRANS_NO,
        TRANS_DATE,
        DR_AMT,
        CR_AMT,
        PARTICULAR
      }, index) => {
        /* Calculatation*/
        oprningbalance += CR_AMT
        oprningbalance -= DR_AMT

        document.getElementById('output2').innerHTML += `<tr>
          <td>${index + 1}</td>
          <td class="text-tiny text-break">${moment(TRANS_DATE).format('LLL')}</td>
          <td class="text-tiny">${TRANS_NO}</td>
          <td class="text-tiny">${DR_AMT.toFixed(2)}</td>
          <td class="text-tiny">${CR_AMT.toFixed(2)}</td>
          <td class="text-tiny">${oprningbalance.toFixed(2)}</td>
          <td class="text-tiny text-break">${PARTICULAR}</td>
        </tr>`
        total_dr += DR_AMT
        total_cr += CR_AMT
      })
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this instead

document.getElementById('output2').innerHTML = payload.map(({TRANS_NO,TRANS_DATE,DR_AMT,CR_AMT,PARTICULAR}, index) => {
  /* Calculatation*/
  oprningbalance += CR_AMT
  oprningbalance -= DR_AMT
  total_dr += DR_AMT
  total_cr += CR_AMT
  return `<tr>
          <td>${index + 1}</td>
          <td class="text-tiny text-break">${moment(TRANS_DATE).format('LLL')}</td>
          <td class="text-tiny">${TRANS_NO}</td>
          <td class="text-tiny">${DR_AMT.toFixed(2)}</td>
          <td class="text-tiny">${CR_AMT.toFixed(2)}</td>
          <td class="text-tiny">${oprningbalance.toFixed(2)}</td>
          <td class="text-tiny text-break">${PARTICULAR}</td>
        </tr>`
}).join("")
about 4 years ago · Juan Pablo Isaza 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