Hello I am new in react native and I want to merge data using Object.assign()
.
I tried with simple arrays and everythings work but my array is more than array in one big array.
My code:
let o1 = getCartData; // [{productId:56, productQuantity:1}, {productId:4, productQuantity:1}]
let o2 = resultObject; // product with different quantity {productId:56, productQuantity:5}
let finalObj = Object.assign([], o1, o2);
console.log('Final', finalObj); // Output ▼["[","{",""","p","r","o","d","u","c","t","I","d",""",":","5","6",",",""","p","r","o","d","u","c","t","Q","u","a","n","t","i","t","y",""",":","1","}","]"]
I want to get this output:
console.log('Final', finalObj); // Merged [{productId:56, productQuantity:5}, {productId:4, productQuantity:1}]