I have the following code and I'm trying to calculate the total of all items added to the cart. When I use reduce I don't get back anything but while troubleshooting I added a map in there (commented out code) and that prints a value. I can add more code here but so you know everything is working fine. I am able to see data in the cart which is an array of objects. I just need to iterate over and calculate the total price. Please advise.
this.store.select('cart').pipe(reduce((accumalatedTotal, cartItem) => accumalatedTotal + (cartItem.price), 0))subscribe((val:number) => console.log("===>>>", val));
//this.store.select('cart').pipe(map(cartItem => cartItem.price)).subscribe((val:number) => console.log("===>>>", val));
With that commented out map I can print the item price but I cannot see anything with reduce.