Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda