How to filter a javascript array with multiple matching conditions.
The below code returns all the data, instead of just 2.
Code:
this.entityTypes = codeList.Values.filter(c => c.CodeValue === 'CRD_CRE_INS' || 'CRD_EEA_BRA');
Sample JSON Array:-
const codeList.Values = [{
"CodeValue": "CRD_CRE_INS",
"CodeValueDisplay": "CRD Credit Institution",
},
{
"CodeValue": "CRD_EEA_BRA",
"CodeValueDisplay": "EEA Branch",
},
{
"CodeValue": "CRD_NON_EEA_BRA",
"CodeValueDisplay": "Non-EEA Branch",
}
]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…