Looking to compare two arrays - one old and one new. The initial data set includes:
[
{"member_name":"Test1","item":"Sword"},
{"member_name":"Test2","item":"Sword"}
]
The updated set now includes:
[
{"member_name":"Test1","item":"Sword"},
{"member_name":"Test2","item":"Sword"},
{"member_name":"Test1","item":"Shield"}
]
Test1 has acquired a new item. I've attempted various methods to compare these arrays without success.
Methods attempted:
This method returns the entire array, not individual items:
Items_Curr.filter(function(item) { return !Items_Prev.includes(item); });
This method results in 3 undefined values:
Items_Curr.map(e => { e.member_name });
I have been searching for a solution, but most advice addresses simpler array comparison scenarios.
For example: [a,b] - [a, b, c]
Update:
The objective is to create a new 'NewItems' array that will include all newly added names and items. Any changes should be broadcasted, otherwise ignore until the function is run again.