I would like to read array2 and remove items from array1 and add new item to array1:
If parameter "Removed" is 1 then i want to remove this item. If parameter "Removed" is 0 then i want to add item.
How can I make the following solution using javascript?
I have two arrays:
var array1 = [
{ItemId: "1", Name: "John"},
{ItemId: "2", Name: "George"},
{ItemId: "3", Name: "Peter"}
]
and
var array2 = [
{ItemId: "1", Name: "John", Removed: "1"},
{ItemId: "4", Name: "Mario", Removed: "0"},
{ItemId: "5", Name: "Mike", Removed: "0"}
]
I want following result:
var array1 = [
{ItemId: "2", Name: "George"},
{ItemId: "3", Name: "Peter"},
{ItemId: "4", Name: "Mario"},
{ItemId: "5", Name: "Mike"}
]