Refactor Nested Conditionals into a Rule Table (TypeScript)

Asked at Salesforce · Coding Questions · Difficulty: Medium · Last asked Feb 5, 2026

A shipping-fee function in a TypeScript codebase has grown into a tangle of nested `if/else` branches with the same arithmetic repeated in several places. Refactor it into a table-driven design without changing what it returns, and protect the change with tests.

Loading the problem…