so im trying to find a more efficient way to write the following code.
cartState.forEach((cart) => subTotal += cart.price);
I feel like if cartState is quite large, and becuase each cart object is quite large in itself. so purely performance or best practices is there a better way to do this?
Heres the array
const cartState = [
    {
      name: 'xxx',
      price: 'xxx',
    },
]
Just as an edit, this isn't just for adding totals, it's also for combining values into an array.
 
    