Skip to content

Instantly share code, notes, and snippets.

@ElemarJR
Created November 2, 2012 23:41
Show Gist options
  • Select an option

  • Save ElemarJR/4005049 to your computer and use it in GitHub Desktop.

Select an option

Save ElemarJR/4005049 to your computer and use it in GitHub Desktop.
var numbers = [1,2,3,4,8];
var q = _.countBy(numbers, function(x) { return x % 2 == 0 ? 'even' : 'odd'; } );
// q = { "odd": 2, "even": 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment