Is there a way to simplify the below logic to use less than 5 operators (&& / ||)
without creating new variables?
var foo = (A || B) && C && [(A && D) || (B && E)]
Is there a way to simplify the below logic to use less than 5 operators (&& / ||)
without creating new variables?
var foo = (A || B) && C && [(A && D) || (B && E)]
Assuming []
means ()
, then you could drop some parenthesis, because of the operator precedence of &&
(6) over ||
(5).
var foo = (A || B) && C && (A && D || B && E);
Then you could drop the first part, because of the condition in the last part,
var foo = (A || B) && C && (A && D || B && E);
// ^ ^ ^ ^
because not only A
has to be true
as well as D
or B
has to be true
and E
as well.
var foo = C && (A && D || B && E);