jeudi 25 juin 2020

How to know which booleans are true inside If statement in JS?

I want to know if if statement is true then which booleans are true inside the condition?

I mean I have this code:

var a = true;
var b = false;
var c = true;

if (a || b || c) {
   alert('Here I want to alert a and c. Because they are true.');
}

I think I can do it with for or while. For example checking all variables again inside if statement, but can I do it with less code or more efficient way?

Aucun commentaire:

Enregistrer un commentaire