Grouping Data with Lodash
In this lab, you will be using the
_.groupBy() function provided by the Lodash library to group data from an array of objects. The
_.groupBy() function takes two arguments: an array of objects and a property to group by. It returns an object with the groups as properties.
To complete this lab, you need to export a groupBy function from your
index.js file. The function will take two arguments:
data (an array of objects) and
property (a string representing the property to group by). The function should use the Lodash
_.groupBy() function to group the input data and return the result. The Lodash library is already installed in this lab, so feel free to use any function provided by it.
The Lodash library is already installed for this lab with
import _ from 'lodash'.