mardi 22 septembre 2020

Javascript AND OR operators and parentheses

Having issues correctly triggering code in an if and or statement. I want the code in the statement to run when the defholdid var is equal to "cb_SR" AND if ANY of these variables are true: altRighttargets, inRightTargets, safetyRightTargets. I have checked each variable on their own and they all receive the values I expect. Here's the statement:

 if (defholdid === "cb_SR" && (altRightTargets === true || inRightTargets === true || safetyRightTargets === true)) {
        //code I want to trigger
};

I checked the statement with each individual expression, and I can get the code to trigger, so I think I'm incorrectly writing the statement.

Thanks,

Aucun commentaire:

Enregistrer un commentaire