Given the following array of objects how can I go about creating a new one in which if there is an object with same email it just add the favoriteSport to an array. What I want to achieve is to remove the duplicate data.
Any tips on how to tackle this in Javascript?
data = [
  { 
    name: 'Lisa Simpson',
    email: 'lisa@email.com',
    favoriteSport: 'Soccer' 
  },
  { 
    name: 'Lisa Simpson',
    email: 'lisa@email.com',
    favoriteSport: 'Tennis' 
  },
  { 
    name: 'Lisa Simpson',
    email: 'lisa@email.com',
    favoriteSport: 'Swimming' 
  },
  { 
    name: 'Lisa Simpson',
    email: 'lisa@email.com',
    favoriteSport: 'Voleyball' 
  }
]
//Expected Output
[
  {
      name: 'Lisa Simpson',
      email: 'lisa@email.com',
      favoriteSport: ['Soccer', 'Tennis', 'Swimming', 'Voleyball']
  }
]
 
     
     
     
     
    