The issue I'm facing with the code below is that it only displays the quantity of the first item, rather than all items in my shopping cart.
import {ShoppingCartItem} from './shopping-cart-item';
export class ShoppingCart {
constructor(public items: ShoppingCartItem[]) {}
get totalItemsCount() {
let count = 0;
for (const productId in this.items) {
if (this.items.hasOwnProperty(productId)) {
count += this.items[productId].quantity;
return count;
}
}
}
}