43.groupBirthdays

Write a function named groupBirthdays that receives 2 parameters:

  • an Array of users each with 2 properties:
    • name - a string representing the user's name
    • birthday - a Date representing the user's birthday
  • a groupBy string with one of the following values - month, day, year

The function should group the users according to their birthdays and the groupBy parameter, and return a Map where the values are Arrays of users, and the keys are:

  • index of the month if groupBy="month" (starting from 1)
  • index of the day in a month if groupBy="day" (starting from 1)
  • year if the grouping string is groupBy="year"

Example 1

Input

users

=

groupBy

=

Output