#Restaurant ordering app
1 messages · Page 1 of 1 (latest)
Your total is incorrect because you never set it back to 0 when calculating the total... in getOrderedItems() you need to set total = 0 just before the forEach otherwise previous items are counted multiple times...
Your remove isn't working because you do this:
delete selectedItems[itemId]
So you're accessing your selectedItems by itemId but that's not correct... you should be accessing it by index - this is not a Map or some other kind of lookup but a simple array... in other words if you first add a beer (id=2) and it's the only thing on the list (so it's at index 0) then you try to remove it, that results in
selectedItems[2] // cause beer is id 2
But that won't work because the beer is at index 0. So you need to re-work the way you track items... if you want to keep the unordered array like you have now, you should instead set the data-remove to the index of the array instead of the menu id...