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…
More Salesforce interview questions
- Campaign Cost Weekly Partition
- Design a Collaborative Spreadsheet (Google Sheets)
- AI / ML Fundamentals Oral Round (AI Engineer)
- Rate Limiter for Expensive API with User-Configurable Monthly Quota
- Hiring Manager + Behavioral Rounds
- Design an Async Job / Task System