+ 4
Why JavaScript return false in this case?
var a = 10; b = 20; c = 30; console.log( c > b > a) //false
4 Answers
+ 13
Associativity for > operator in JS is left to right.
c > b > a
is evaluated as
(c > b) > a
(30 > 20) > 10
true > 10
JS converts true to 1 and executes comparison
1 > 10
false
+ 3
A similar question in C language.
https://www.sololearn.com/Discuss/2140916/?ref=app
+ 1
Hatsy Rei i understand your explanation. I recently had a problem like this in python. Is there a way we can do this?
I want a user to input an integer n, between 2 to 5 and output a string if the input is even.
Tried doing this
if n % 2 == 0 and 2 == n <= 5:
print ("Not Weird")
.....
Didn't work. I tried another way and got it.
Sorry for the long story but is there a way we can write this an one expression instead of two?
0
thanks its clear now