Path to Functional Style: a TypeScript Refactoring Example

How to refactor a function from imperative style to functional style

This article talks about how to refactor a function with imperative style into functional style. The function is refactored in a few passes and I will discuss the rationale of the changes.