Typescript Functional Programming Vs Imperative Programming