Reputation: 95
Is this ok way to check if all 4 variables have same value instead of checking each individually?
if (bodovi >= min_bodovi && (Q15,Q16,Q17,Q18) == true)
Upvotes: 0
Views: 46
Reputation: 2795
Will validate only the last variable, here if Q18 is true then the condition will just pass even if Q15,Q16,Q17 are false or any one of them false.
(Q15,Q16,Q17,Q18) == true
You can use (Q15 && Q16 && Q17 && Q18)
Upvotes: 0
Reputation: 4125
You can simplify that to:
if (bodovi >= min_bodovi && Q15 && Q16 && Q17 && Q18)
Given that these are boolean variables, their value being TRUE is sufficient for javascript to evaluate each as TRUE. If one of them id false, e.g. Q15 = false
, then it will fail
Upvotes: 2