Skip to content

Instantly share code, notes, and snippets.

@tuxsudo
Created January 27, 2016 17:18
Show Gist options
  • Select an option

  • Save tuxsudo/71b2f821e11a0bc492d8 to your computer and use it in GitHub Desktop.

Select an option

Save tuxsudo/71b2f821e11a0bc492d8 to your computer and use it in GitHub Desktop.
// ( (fn=>true), Array ) => { "true": [], "false": [] }
function splitArray(fn, arr) {
return arr.reduce((last, current) => {
let key = fn( current ).toString();
last[key] = last[key].concat(current);
return last;
}, { "true": [], "false": [] } );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment