30th Oct 2019, 5:34 PM
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎ - avatar
3 Respuestas
+ 4
if (!(a++>=10 || b++>=11)) Short-circuit evaluation 🤔 Your condition combines 2 logical expressions . It's combination of a++>=10 and b++>=11 . If any of the both expressions is true in this statement the result of entire statement will be true. When first operand is true logical OR will not evaluate second operand . And here a++>=10 is true so second expressions never gets evaluated! And hence no increment in `b` take note that this happens in case of logical AND also. if first operand is false second one won't be checked . Read *Short-circuit evaluation* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators
30th Oct 2019, 5:46 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 2
When you use the || if the first condition is true it won't check the other condition since only one condition has to be true. So it checks "a" sees that the first condition is true and doesn't check b, hence why it doesn't increment.
30th Oct 2019, 5:39 PM
Odyel
Odyel - avatar
30th Oct 2019, 6:15 PM
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎
Oneill~Онеилл~奥尼尔~ओनील~اونیل~*‎ - avatar