+ 1
Can anyone explain to me why the result of that condition is 2 in the code below ? It doesn't make any sense to me
5 Answers
+ 1
Knowing that,
var a = 10, b = 20, c = 30;
if(c > b > a) is evaluated from left to right because same operator is used.
`c > b` (or 30 > 20) evaluates to true (numerically, true equals to 1)
Then the above result is evaluated as `1 > a`. Remember <a> is 10, thus it is evaluated as `1 > 10`, which results false (numerically, false equals to 0).
The execution flow then runs to the `else` block because the final evaluation result yields false : )
+ 2
if(c>b&&b>a)
+ 1
Ipang thanks now it makes a lot more sense
0
You're welcome Ămer Ayhan đ