Loops efficiently iterate over all items to count them.
Loops allow you to iterate over each item in a cart, incrementing a counter for each one. This is straightforward and efficient for counting all items, giving you the total number of items in the cart.