I'm relatively new to to objects and objects with arrays, so here in my screenshot I want to check if for each value in fieldValue if it exists in (from 1st part of image) the id part, so if any value in fieldValue matches any value of the id, then -> perform an action, else if it doesn't then pop the value from fieldValue.
eg: in fieldValue we have ['1', '2'], so I need to access these and then compare, so for 1 check in the above object in all the ids if it exists or not. If not pop that value from fieldValue
(11) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {id: 1, name: 'Product & Sales Campus', shortname: '1'}
1: {id: 2, name: 'Quality Campus', shortname: '2'}
2: {id: 3, name: 'Business Campus', shortname: '3'}
3: {id: 16, name: 'Operation Campus', shortname: '16'}
4: {id: 38, name: 'Customer Service Campus', shortname: '38'}
5: {id: 44, name: 'Programa Initium', shortname: '44'}
6: {id: 67, name: 'Russia', shortname: '67'}
7: {id: 70, name: 'PXSN Test Catalog', shortname: '70'}
8: {id: 72, name: 'QA Production Catalog', shortname: '72'}
9: {id: 77, name: 'Systems and Applications', shortname: '77'}
10: {id: 160, name: 'TestGroup', shortname: '160'}
length: 11
[[Prototype]]: Array(0)
[{…}]
0:
fieldName: "cataloggroup"
fieldValue: (2) ['1', '2']
operator: "Equals To"
[[Prototype]]: Object
length: 1
[[Prototype]]: Array(0)
This is what I got so far based on link share by @evolutionbox
for(let m = 0; m < temparray.length; m++){
const fieldValueItem = temparray[0].fieldValue[m];
for(let n = 0; n < this.allMasterFltrdata[$event].length; n++){
const allMasterFltrdataItem = this.allMasterFltrdata[$event];
if(fieldValueItem == allMasterFltrdataItem){
console.log("true");
}
else{
console.log("false");
}
}
}
so in this.allMasterFltrdata[$event]; the $event comes from the function parameters that value is $event it is text value, so how to add index here for n?
Thank you in advance.