Mapping elements of an array to a property within an Array on object
If I have a sample data that looks like this:
let result = [{
type: ['Science', 'Business'],
link: "www.educatorsector.com"
},
{
type: ['Sports', 'News'],
link: "www.skysports-news.com"
},
{
type: ['Sports', 'Health', 'Science'],
link: "www.cnn-news.com"
},
{
type: ['Health'],
link: "www.healthsector.com"
}
];
finalResult: [{ "type" : "Science", "numberOfLinks" : 2 }, { "type" : "Business","numberOfLinks" : 1 }, { "type" : "Sports", "numberOfLinks" : 2 }, { "type" : "News", "numberOfLinks" : 1 }, { "type" : "Health", "numberOfLinks" : 2 }]
OR the type with the an array of the corresponding links it has.
from Recent Questions - Stack Overflow https://ift.tt/3maUZUf
https://ift.tt/eA8V8J
Comments
Post a Comment