如果我有一个看起来像这样的示例数据,我需要从结果数组中获取 finalResult 数组:
let result = [{
type: ['Science'],
link: "www.educatorsector.com"
},
{
type: ['Sports', 'News'],
link: "www.skysports-news.com"
},
{
type: ['Sports', 'Science'],
link: "www.cnn-news.com"
}];
finalResult = [
{ type : "Science", numberOfLinks : 2 },
{ type : "Sports", numberOfLinks : 2 },
{ type : "News", numberOfLinks : 1 }]
orThisFinalResult = [
{ type : "Science", links : ["www.educatorsector.com", "www.cnn-news.com"],
{ type : "Sports", links : ["www.skysports-news.com", "www.cnn-news.com"],
{ type : "News", links : ["www.skysports-news.com"]
}