Partition On

1
2
3
4
5
6
7
function partitionOn(pred, items) {
var falsies = items.filter(function (num) {return !pred(num)}),
truths = items.filter(pred),
newArr = falsies.concat(truths);
for (var i = 0; i < newArr.length; i++) items[i] = newArr[i];
return falsies.length;
}