How to find and replace over deep nested array object in javascript
I have a sample object name obj and filtered the object by id, in , and out(obj_res).
How to find and update the particular obj with id fund in obj_res in javascript as shown in expected output
I got stuck need help how to do in javascript
var obj_res = getValue("bank", "bank", "trans");
function getValue(send, receive, id){
const temp = obj.map(e => Object.entries(e).map(([k, val]) => val)).flat(3)
result_obj = temp.filter(x=>x.in ==send && && x=>x.out ==receive && x.id == id);
return result_obj;}
//whole object input
var obj = [{
"btob": [{
"id": "trans",
"in": "bank",
"out": "bank",
"value": 10,
},{
"id": "fund",
"in": "bank",
"out": "bank",
"value": 10
}],
"ctob": [{
"id": "trans",
"in": "credit",
"out": "bank",
"value": 20
},{
"id": "fund",
"in": "credit",
"out": "bank",
"value": 10
}]
}]
//resultant obj after filter by id , in ,out
var obj_res =[{
"id": "trans",
"in": "bank",
"out": "bank",
"value": 10
},{
"id": "fund",
"in": "bank",
"out": "bank",
"value": 10
}]
Expected Output:
res=[{
"id": "trans",
"in": "bank",
"out": "bank",
"value": 10
},{
"id": "fund",
"in": "credit",
"out": "bank",
"value": 10
}]