Here is the code I have written:
this.temp1.push(this.json);
for(let i=0; i<this.temp1.length; i++){
if(this.temp1[i].name == this.json.name){
this.orderList[i] = this.json;
this.DBorder[i] = this.order_json;
}
else{
this.orderList.push(this.json);
this.DBorder.push(this.order_json);
}
}
This is my first input data:
[{"name":"Pad-Thai", "price":10,"amount":1,"total":10}]
Here is my second input data, now with a new amount included:
[{"name":"Pad-Thai", "price":10,"amount":3,"total":30}]
The current result of the process is as follows:
[{"name":"Pad-Thai", "price":10,"amount":3,"total":30},
{"name":"Pad-Thai", "price":10,"amount":3,"total":30}]
However, the expected result should be:
[{"name":"Pad-Thai", "price":10,"amount":3,"total":30}]