Since you tagged your post #functional: The way you implemented both functions they are not really functions but impure actions. In a functional setting you would further defer effect execution after passing args by wrapping the result in a special effect or IO type. Then you can compose values of this type in a purely functional manner and only unleash the composed effects at the edge of your application.
I'll let you explain to the author of the book "Discover Functional Programming in JavaScript", Cristian Salcescu, that his code is impure (since, as I said in my post, the implementations are from his book).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Since you tagged your post #functional: The way you implemented both functions they are not really functions but impure actions. In a functional setting you would further defer effect execution after passing
args
by wrapping the result in a special effect or IO type. Then you can compose values of this type in a purely functional manner and only unleash the composed effects at the edge of your application.I'll let you explain to the author of the book "Discover Functional Programming in JavaScript", Cristian Salcescu, that his code is impure (since, as I said in my post, the implementations are from his book).