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

211
Vistas
How to set each value of the array equal to prevent value - 80 in the following loop only if it's not the first item (JS)

I have an array of objects that contains numeric values. When I loop through it I need to set in the following logic the values in a way that each value starting from second element is equal to the previous value -80

  result.data.forEach((dataItem) => {
        if (dataItem.values && dataItem.values.length) {
          dataItem.sumValue = dataItem.values.reduce((sum, item) => {
            return (sum + item.value)
          }, 0)
        } else dataItem.sumValue = dataItem.value

So each dataItem.sumValue should be equal to the previous value -80.

How can it be achieved?

about 4 years ago · Juan Pablo Isaza
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