Grouped Array in JS

PHOTO EMBED

Thu Sep 15 2022 03:31:16 GMT+0000 (UTC)

Saved by @GodFather #html

var invoiceStudentByGroup = _.mapValues(_.groupBy(invoiceStudent, 'invoice_type'), clist => clist.map(res => _.omit(res, 'invoice_type')));

[
  0: {
  	name: yusup
  	home: bogor
  }
  1: {
    name: samuel
    home: jakarta
  }
  2: {
    name: salsa
    home: bogor
  }
  
] 

Result

[
  bogor: [
  	0: {name: yusup, home: bogor}
    1: {name: salsa, home: bogor}
  ],
  Jakarta: [
    0: {name: samuel, home: jakarta}
  ]
]
content_copyCOPY