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

271
Views
How to display moths payment as sum for each year, using Array, loop etc?

I had problem with my new calculator because one date was showed as year (25year) and second as moths (300moth). After many attempts I finally find 2 good working solution to change month to year:

var kopia = [];

  for(var i = 0; i < chart1.length; i++){
    kopia.push(chart1[i]/12) 
  }
  
    const dublicateItems = (arr, numberOfRepetitions) => 
    arr.flatMap(i => Array.from({ length: numberOfRepetitions }).fill(i));


var finalnywynik = dublicateItems(kopia, 12);

and

newArray = new array();
for(i=0;i<chart. length; i++){
for(j=0;i<12; j++){
newArray[j] += chart1[i]
}}

but it do not look cool on chart so now I think how map another chartdate to look it more clean by reduce them to.

My attempts to reduce months to years just give a sum of each month and previous payment. It is useful, but not in this case:

import { create, all } from 'mathjs'

const config = { }
const math = create(all, config)

var r =  RataBezDotacji;
var payment = 0;
if (r.length) { 
  for (var i = 0, h = r.length; i < h; i++) { 
 payment = math.sum(payment, r[i]['payment']); 
 if((i+1)%12 || i+1 == h) 
{ 
  RataBezDotacjaa.push(payment.toFixed(2))
} 
} }

Please indicate correct solution, to bring my project to a final deployment.

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!