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

283
Vistas
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
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