here is the some sample line of codes..
if(loc > 0 || cat > 0 || price > 0 || jsBed <= bedroom || jsBuilt >= built) {
/// Condition to checn all true
return true;
} else if(loc < 0 || cat > 0 || price > 0 || jsBed <= bedroom || jsBuilt >= built) {
/////// 1 false other are true
} else if(loc > 0 || cat < 0 || price > 0 || jsBed <= bedroom || jsBuilt >= built) {
}
How to handle these condition. if i have 5 statement. Then it must be almost 12+ condition one by one.. if i am checking all the 5 combinations its going to more lines of code do we have any better option to check all the conditions.
If you treat a boolean expression as an integer in javascript, it will evaluate to
0
(forfalse
) or1
(fortrue
). So you could sum the conditions and then use a switch-case construct to check how many were true: