How can I create arrays to group members depending on their tag?
Tags can be anything, these are just examples.
Example Input
[
  { tag: 'Red', member: 'Red-Steve' },
  { tag: 'Red', member: 'Red-Adam' },
  { tag: 'Blue', member: 'Blue-John' },
  { tag: 'Blue', member: 'Blue-James' },
  { tag: 'Blue', member: 'Blue-Igor' }
]
Example Output
{
  Red: ['Red-Steve', 'Red-Adam']
  Blue: ['Blue-John', 'Blue-James', 'Blue-Igor']
}
Edit: I just made a test case on jsperf to compare the efficiency of the different answers and also the answer from the suggested duplicate question
https://jsperf.com/group-objects-reduce-vs-for-loop
The answer by @Majed Badawi was the most efficient
 
     
     
     
    
