A checkout function becomes difficult to change when validation, price lookup, normalization and formatting all update the same variables. A useful refactor gives each decision a boundary and makes external data an explicit dependency.
You work with small retail and logistics functions whose policies are fully specified. Preserve duplicates when they represent separate requests. Treat a zero price as a known value, and reject boolean quantities when the contract requires an integer count. Those details are easy to lose while shortening code. The goal is behavior you can explain and test, rather than the shortest expression. A pure helper returns a result from its inputs, which lets you exercise the rule without contacting a service or configuring global state.