forEach is not a function error

I understand that there’s more code. But the aggregateCart function you pasted in the first post is wrong, because inside of this context, cart is a string and not an array.