Create a new function that calls the provided fn and then inverts the sign of the result.
fn
Time complexity: O(1)
Space complexity: O(1)
The inverted return value of fn
Higher order
function sort(a, b) { return a - b;}const inverted = invert(sort);inverted(10, 5); // -5 Copy
function sort(a, b) { return a - b;}const inverted = invert(sort);inverted(10, 5); // -5
Create a new function that calls the provided
fnand then inverts the sign of the result.Time complexity: O(1)
Space complexity: O(1)