In the following code, what is the opposite of the condition (ran1 <= 63 && ran2 <= 18), which should fit in the else portion of the if statement?
Is it both (ran1 <= 63 || ran2 <= 18) and (! (ran1 <= 63 && ran2 <= 18))?
Logically, I suppose that the opposite of A and B is both A or B and neither A nor B. But I'm not sure how to express the neither A nor B bit in JavaScript.
var ran1 = 1 + Math.floor(Math.random() * 100);
var ran2 = 1 + Math.floor(Math.random() * 100);
if (ran1 <= 63 && ran2 <= 18) {
// code
} else {
// code
}
The mathematical negation of A && B is !A || !B, so in your case, it would be
ran1 > 63 || ran2 > 18
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With