Consider the following two arrays:
var searchResultsArray = [{"username": "abc", "userid": 23213}, {"username": "def", "userid": 45646}, {"username": "ghi", "userid": 9898}…..]; // size is 100
var connectionsResultsArray = [{"username": "abc", "userid": 23213}, {"username": "xyz", "userid": 7868}, {"username": "ghi", "userid": 9898}…..]; // size is 300
Modify the first array (searchResultsArray
) by adding a new key called 'connected'. If an element exists in the second array, set this key to 'yes', otherwise set it to 'no'.
Example output:
var connectedSearchResultsArray = [{"username": "abc", "userid": 23213, "connected": "yes"}, {"username": "def", "userid": 45646, "connected": "no"}, {"username": "ghi", "userid": 9898, , "connected": "yes"}…..]; // size is 100