I got an initial array, I am checking against another array to find how many objects have at least one instance of the Domain
in data.
I wonder if there is a more performant way to achieve the same goal.
const data = [
{
Domain: 'google.com',
'# Reocurring Domains': 0
},
{
Domain: 'apple.com',
'# Reocurring Domains': 0
},
{
Domain: 'facebook.com',
'# Reocurring Domains': 0
}
]
const domains = [
{
'google.com': true,
'microsoft.com': true,
'google.com': true
},
{
'apple.com': true,
'microsoft.com': true,
'twitter.com': true
},
{
'facebook.com': true,
'apple.com': true,
'facebook.com': true
}
]
for (const obj of data) {
let count = 1
for (const entry of domains) {
if (entry[obj.Domain]) {
obj['# Reocurring Domains'] = count++
}
}
}
console.log(data)
In there any way to this with a more performant approach?