fjs.partition items in array

fjs.partition

fjs.partition returns an array of two arrays. The first array is all items that return true for the iterator function, the second array is all items that return false for the iterator function (i.e. the rest).

Usage

fjs.partition(iterator, items);

Example

var even = function (item) {
return item % 2 === 0;
};
var partitionEven = fjs.partition(even);
partitionEven([7, 6, 5, 4, 3, 2, 1]);
// => [[6, 4, 2], [7, 5, 3, 1]]