angulartoarraymergemap

Angular groupby and merge array


1

I am trying to merge duplicate value objects in an array but not working... I have my result like this

but I want my data like this help me pls

this is my code

-

     dataa = [
           {
             date: '07/05/2020 00:09',
             id: '5920501995',
             score: 0,
             student: 'boon boon',
           },
          ....] 
source = from(this.dataa);
//group by age
 example = this.source.pipe(
  groupBy(person => person.id),
  // return each item in group as array
  mergeMap(group => group.pipe(toArray())));
 subscribe = this.example.subscribe(val => console.log(val));
 - 


Solution

  • instead of logging, you can push to another variable

    const values= [];
    const subscribe = example.subscribe(val => {
    values.push(val);
    });