Adding decimal numbers instead of concatenating

Discussão em 'Angular' iniciado por RRB, Novembro 4, 2024.

  1. RRB

    RRB Guest

    I am trying to sum multiple decimals numbers together however when I console the result it is showing a concatenated result with an undefined in front of it

    for (let i = 0; i < this.performInternationalSwiftPaymentsService.bopSplit.length; i++) {
    this.totalZARForeign += this.performInternationalSwiftPaymentsService.bopSplit.randValue;
    }
    console.log(this.totalZARForeign)


    console result --> undefined4752.861188.22

    The result I want is for it to add 4752.86 and 1188.22 together in this example

    Any idea what I am doing wrong. I also tried adding a parseFloat here this.totalZARForeign += parseFloat(this.performInternationalSwiftPaymentsService.bopSplit.randValue); but then I get NaN in the console result

    Continue reading...

Compartilhe esta Página