If I have a sample data that looks like this I need to get finalResult array from result array:
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"]
}