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

205
Views
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
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!