The article I read provides this as an example of an impure function (in JavaScript):
const tipPercentage = 0.15; const calculateTip = cost => cost * tipPercentage;
This seemed like a slightly strange example to me, since tipPercentage is a constant with an immutable value. General examples of pure functions allow dependence on immutable constants when these constants are functions.
const mul = (x, y) => x * y const calculateTip = (cost, tipPercentage) => mul(cost, tipPercentage);
In the example above, correct me, if I am mistaken, calculateTip usually classified as a pure function.
So my question is: in functional programming, a function that is still considered clean if it relies on an external defined constant with an immutable value when that value is not a function?
source share