It will return the same value if you call it with same variable, because PI is a constant.
If you use replace PI with 3.14159 or Math.PI, it should still be a pure function.

Yes, Maple, maybe my example was a bit confusing. My attempt was to show that the "constant" PI (an external variable) could change (in my example, I changed it to 42).

If the PI value changes, our calculateArea function will change the output for the same input (radius). The whole idea is to show that the function to be pure, it needs to not change the output, for the same input.

I will try give another example with a variable instead of a constant.

I thought

`caculateArea`

is a pure function.Am I understand wrongly?It will return the same value if you call it with same variable, because

`PI`

is a constant.If you use replace

`PI`

with`3.14159`

or`Math.PI`

, it should still be a pure function.Yes, Maple, maybe my example was a bit confusing. My attempt was to show that the "constant"

`PI`

(an external variable) could change (in my example, I changed it to`42`

).If the

`PI`

value changes, our`calculateArea`

function will change the output for the same input (`radius`

). The whole idea is to show that the function to be pure, it needs to not change the output, for the same input.I will try give another example with a variable instead of a constant.

For the input

`100`

, we will have`120`

as a result. But if our tax changes, our output will change, for the same input (`100`

).To make our function pure, we can pass the

`tax`

variable to the function as a parameterFor the inputs 100 and 20, it will always be 120

For the inputs 100 and 100, it will always be 200

With this example it is a bit less confusing I think.

Thanks for the feedback!