I’m looking for solution – group array of objects by value based on matched pattern of other array value.
have sample array
data = [
{
"Application": "Chrome - 567"
},
{
"Application": "File Transfer Protocol - 45"
},
{
"Application": "Google APIs - 3618"
},
{
"Application": "Google Generic - 943"
},
{
"Application": "Google Search - 54"
},
{
"Application": "Microsoft - 2821"
},
{
"Application": "Microsoft DFSR (Distributed File System Replication) - 3722"
},
{
"Application": "Microsoft Remote Procedure Call - 742"
},
{
"Application": "Telegram- 2235"
},
{
"Application": "Facebook Videos - 2250"
},
{
"Application": "Facebook - 690"
}
]
Other array
var Appdata = [Google, Facebook, Instagram, Microsoft, Telegram]
expected result
result = [
{
"Application": "Chrome - 567"
},
{
"Application": "File Transfer Protocol - 45"
},
{
"Application": "Google"
},
{
"Application": "Microsoft"
},
{
"Application": "Telegram"
},
{
"Application": "Facebook"
}
]
there are two separate array data
and Appdata
in data
array if we match the string of Appdata
array then it should replace with Appdata
array value in original data
array
kindly helps to find the solution for this array.
3
Answers
many ways to do this…