November 2017
Intermediate to advanced
386 pages
9h 22m
English
In the Logically negating a function section of Chapter 6, Producing Functions - Higher-Order Functions, we wrote a not() function that, given another function, would logically invert its result. We used that function in order to negate a check for negative balances; sample code could be as follows:
const not = fn => (...args) => !fn(...args);const positiveBalance = not(isNegativeBalance);
In another section of that very same chapter, Turning operations into functions, I left you the challenge of writing a unaryOp() function that would provide unary functions equivalent to common JS operators. So, if you are able to write the following:
const logicalNot = unaryOp("!");
Then, assuming the existence of a compose() function, ...