// Memorize this function! Be able to transform an array of objects into // a normalized object based on a key. Looking up an item in an array is a O(n) // operation if you don't know the item's index. If you know a value on the // item, and that value is unique, you can create an index based on that value // to enable you to do O(1) look ups
const indexArrayBy = key => array => {
return array.reduce((acc, cur) => {
acc[cur[key]] = cur;
return acc;
}, {});
};