Exercise 3: Grouping array values and generating a document count for each group