I have two JS arrays. They are arr1 and arr2. I want to create another array called arr3. Now it wants to compare arr1 and arr2 and insert all elements which arr2 contains and arr1 not contain.
Example:
arr1:
0:
des: "cont1"
note: "cont1"
pro_code: "XXY"
1:
des: "cont2"
note: "cont2"
pro_code: "NNB"
2:
des: "cont4"
note: "cont4"
pro_code: "QQA"
3:
des: "cont5"
note: "cont5"
pro_code: "GFD"
arr2:
0:
des: "cont1"
note: "cont1"
pro_code: "XXY"
1:
des: "cont2"
note: "cont2"
pro_code: "NNB"
2:
des: "cont3"
note: "cont3"
pro_code: "QAS"
In arr2 contains pro_code: QAS. But it is not in arr1. So it should be contained in arr3.
In arr1 contains arr1[4] pro_code: GFD. it should not be contained in arr3. Becase aar1 can contain additional elements.
Here arr2 must contain elements that are in arr1. There can not additional elements in arr2.
Expected output:
const arr3 = [{
des: "cont3",
note: "cont3",
pro_code: "QAS"
}
My tried code, not workes. Please help me to solve this.
Expected output:I am using this in vuecomputed:theresome()is not working.