Basically if any of the value in mailPrice contain N/A or 'n/a` trying to return true its not happening looks like i am missing something , Also if there is any better approach instead of writing big if condition i would appreciate ?
main.js
const drug = {
"isBrand": false,
"drugName": "Hydr",
"drugStrength": "5mg-300mg",
"drugForm": "Tablet",
"mailPrice": {
"costEmployer": "0.0",
"costToday": "N/A",
"deductible": "n/a",
"memberCopayAmount": "0.00",
"penalties": "N/A",
"totalDrugCost": "0.00"
}
}
const priceFilterHandler = (item) => {
let bRet = false;
if (item.mailPrice.costEmployer === "N/A" || item.mailPrice.costEmployer === "n/a" || item.mailPrice.costToday == "N/A" || item.mailPrice.costToday === "n/a" || item.mailPrice.penalties === "N/A" || item.mailPrice.penalties === "n/a" || item.mailPrice.deductible === "N/A" || item.mailPrice.deductible === "n/a") {
bRet = true;
}
return bRet;
};
console.log(priceFilterHandler(drug));
Aucun commentaire:
Enregistrer un commentaire