Declarative Versus Imperative
There are two general ways to think about writing code: Declarative and Imperative. Code written in the Functional Programming paradigm should be declarative.
Declarative code is code that expresses the logic of a computation without describing its control flow. Imperative code is code that uses statements to change a program's state.
These definitions are difficult to understand if you have never studied declarative and imperative code before. Declarative code is generally used with Functional Programming and imperative code is generally used with Object-Oriented Programming. There is no "right answer" when deciding which coding style to use; they both have their trade-offs. However, declarative code fits the Functional Programming paradigm better than imperative.
Imperative Functions
Imperative code is most common in OOP. The technical definition is complicated, but we can simplify it. An imperative approach to coding is about HOW you solve the problem. Consider...