Adding values in an *ngFor


So I have the following values in my loop:


I have a method:

getTotalAmount() {
    if (this.ordersummary) {
      return => t.order_cost).reduce((a, value) => a + value, 0);
    return 0;

this outputs: 0369369269

Please help, I need these values to be added

have you tried parseInt on the value?

Try this:

... .reduce((a, value) => a + +value, 0);


1 Like

is this a string? that would explain what’s going on. Change it to a number, and maybe things will work

1 Like

ah yes, I had to declare it as a number and remove the ‘’ in the model

What are you trying to accomplish? What isn’t working as expected? Is this a problem with reduce or *ngFor?