Skip to content

Instantly share code, notes, and snippets.

@guifromrio
Created May 25, 2016 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guifromrio/3604ecab4307bcba73be73326e928872 to your computer and use it in GitHub Desktop.
Save guifromrio/3604ecab4307bcba73be73326e928872 to your computer and use it in GitHub Desktop.
var studentsByClass = _.groupBy(students, function (student) { return student.class })
/* {
"A": [
{ name: "John", grades: [7.0, 6.9, 8.0], class: "A" },
{ name: "Paul", grades: [5.0, 8.7, 3.7], class: "A" }
],
"B": [
{ name: "Luke", grades: [9.0, 8.2, 6.2], class: "B" },
{ name: "Mark", grades: [6.0, 9.0, 8.4], class: "B" }
]
} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment