Open
Description
We should have a method that partitions an object based on a certain condition, like this:
helpful.partitionObject({"a": 1, "b": 2, "c": 3, "d": 4}, (key, value) => value > 2) => [{"c": 3, "d": 4}, {"a": 1, "b": 2}]
or:
helpful.partitionObject({"a": 1, "b": 2, "c": 3, "d": 4}, (key, value) => key == "a") => [{"a": 1}, {"b": 2, "c": 3, "d": 4}]
or:
helpful.partitionObject({"a": 1, "b": 2, "c": 3, "d": 4}, (key, value) => true) => [{"a": 1, "b": 2, "c": 3, "d": 4}, {}]
or:
helpful.partitionObject({"a": 1, "b": 2, "c": 3, "d": 4}, (key, value) => false) => [{}, {"a": 1, "b": 2, "c": 3, "d": 4}]
The second parameter should be a function with two arguments, which represents one key-value pair in the object. The return value should be a list containing two objects. The first object should contain all the key-value pairs where the function parameter returns a truthy value, and the second object should contain all the key-value pairs where the function parameter returns a falsey value.
The original object passed into the function should not be altered.