+ 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

https://code.sololearn.com/W92agLPECehJ/?ref=app

21st Feb 2020, 7:02 AM
Ömer Ayhan
Ömer Ayhan - avatar
5 Respostas
+ 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 : )
21st Feb 2020, 7:22 AM
Ipang
+ 2
if(c>b&&b>a)
21st Feb 2020, 7:19 AM
Oma Falk
Oma Falk - avatar
+ 1
Ipang thanks now it makes a lot more sense
21st Feb 2020, 7:31 AM
Ömer Ayhan
Ömer Ayhan - avatar
0
You're welcome Ömer Ayhan 👌
21st Feb 2020, 7:34 AM
Ipang