There was an error while loading. Please reload this page.
Segregate values by test result.
Alternatives: partition, partitionEach. Similar: count, partition.
function partition(x, ft) // x: an array // ft: test function (v, i, x)
const xarray = require('extra-array'); var x = [1, 2, 3, 4]; xarray.partition(x, v => v % 2 == 0); // → [ [ 2, 4 ], [ 1, 3 ] ] var x = [1, 2, 3, 4, 5]; xarray.partition(x, v => v % 2 == 1); // → [ [ 1, 3, 5 ], [ 2, 4 ] ]