Here i want to replace price in data1
to price from data2
, and it updated if the id is same.
Is it possible to do that without nested loop?
var data1 = [{
"id": "56e641d4864e5b780bb992c6",
"price": "1000",
"quantity": "1",
"name": "def"
},
{
"id": "56e65504a323ee0812e511f2",
"price": "2000",
"quantity": "2",
"name": "abc"
}]
var data2 = [{
"id": "56e65504a323ee0812e511f2",
"price": "800",
"name": "abc"
},
{
"id": "56e641d4864e5b780bb992c6",
"price": "900",
"name": "def"
}]
the result that i want looks like this
result = [{
"id": "56e641d4864e5b780bb992c6",
"price": "900",
"quantity": "1",
"name": "def"
},
{
"id": "56e65504a323ee0812e511f2",
"price": "800",
"quantity": "2",
"name": "abc"
}]