Hi,
So I have the following values in my loop:
369
369
269
I have a method:
getTotalAmount() {
if (this.ordersummary) {
return this.ordersummary.map(t => 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?
snigo
3
1 Like
ilenia
4
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
?