In Chapter 1, Becoming Functional – Several Questions, we went over what FP is, mentioned some advantages of applying it, and listed some tools we'd be needing in JavaScript, but let's now leave theory behind, and start by considering a simple problem and how to solve it in a functional way.
In this chapter, we will do the following:
- Look at a simple, common, e-commerce related problem
- Consider several usual ways to solve it, with their associated defects
- Find a way to solve the problem by looking at it functionally
- Devise a higher-order solution that can be applied to other problems
- Work out how to carry out unit testing for functional solutions
In future chapters, we'll be coming back to some of the topics listed here, so we won't be going into too much detail. We'll just show how FP can...