[Solved] remove duplicate key name and group duplicate key related info into array



// if duplicate _id's are allowed for the desc key
const result = [...new Set(articles.map(v => v.key))].map((val => ({key: val, desc: articles.filter(v => v.key === val).map(x => x.desc._id)})));
console.log(result);
// if only unique _id's are allowed
const result1 = [...new Set(articles.map(v => v.key))].map((val => ({key: val, desc: [...new Set(articles.filter(v => v.key === val).map(x => x.desc._id))]})));
console.log(result1);

solved remove duplicate key name and group duplicate key related info into array