Consider the following array of objects:
quesListArray = [
{
QuestionTypeID : 1,
QuestionTypeName : 'Rating'
},
{
QuestionTypeID : 2,
QuestionTypeName : 'Yes/No'
},
{
QuestionTypeID : 3,
QuestionTypeName : 'Rating - Matrix'
},
{
QuestionTypeID : 4,
QuestionTypeName : 'Yes/No - Matrix'
}
]
I am looking for a way to determine if QuestionTypeID 1 & 3 exist in the array, return true, otherwise false. The same applies to QuestionTypeID 2 & 4. Any other combination should result in false.
Initially attempted using a for loop:
for(let x of this.quesListArray) {
if(x.QuestionTypeID == 1 && x.QuestionTypeID == 3) { // realized it's an incorrect condition
// return true or false
}
}
Then I tried using includes() method:
this.quesListArray.includes(this.QuesListArray[..]) // Was uncertain how to structure the conditions for both IDs.
Your guidance on resolving this issue would be greatly appreciated. Thank you.