In lodash there is a method that can be used to break a collection into two groups one of which meets a condition that is given in a function that is passed to it, and another that does not meet that condition. This is of course the _.partition method.
For a quick example of this I thought it would be fun to play with an array that represents a hand of seven French playing cards. The _.partition method can be used to split the collection of objects into two separate groups that meet a given condition, such as if a card has a value greater than or equal to eleven.
In this example I am using _.partition to create an Array of Arrays the first of which is an array of cards that meets the criteria of the condition that I gave it, and the second is everything else that remains. I then used _.each to loop over each of these arrays, and then again to loop over each card.
As such I get what is expected.
So as the name suggested _.partition is useful for well partitioning an array into two arrays one of which meets the conditions given, and the other does not.