Why return a cart object when calling addToCart(..)

You are right that is messy, and NOT the way to do it

well it depends on where your cart lives…I would make a function:

addToCart = cart => items => cart.add(items).

Now addToCart seems pure, but it is not…Notice how I called add on that cart. That means that cart is his hiding state from us, and we just mutated it. Big No No

BUT if I make my cart just a plain ol JS array (or any other Semigroup for that matter) I can THEN:

addToCart = cart => items => cart.concat(items)

And now it is sooo pure. Also because I did the currying like that, I can partially apply ANY semigroup and concat an item to it.

You need to separate ALL of your behavior and data.