+ 1
Why compare work so?
We have consistence (c>b>a), where a=10, b=20, c=30 https://code.sololearn.com/W5gYyDvJN93O/?ref=app
3 odpowiedzi
+ 1
This is how the code works
c > b > a can be written like this
(c > b) > a
The (c > b) will return either true or false which has the value of 1 and 0 respectively. The c > b condition is true, so it becomes like this
1 > a, which is false, thus it prints 2
+ 3
I'm not sure chained comparison operator like that works for JS, I only know it works in Python. In JS multiple expressions evaluation is chained using logical operator, so `if (c>b>a)` could be written as `if (c > b && b > a)` as I understand it.
Hth, cmiiw
+ 1
First comments was right, check code