Category
Create a new function taht calls the provided fn and then inverts the sign of the result.
fn
Time complexity: O(1)
Space complexity: O(1)
Function to invert return value of
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 taht calls the provided
fn
and then inverts the sign of the result.Time complexity: O(1)
Space complexity: O(1)