const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="[mocha template]"> | |
<meta charset="utf-8"> | |
<title>testing on jsbin</title> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/mocha/1.18.2/mocha.css"> | |
</head> | |
<body> | |
<div id="mocha"></div> |