0
Why if else condition is giving wrong output?
if(1<2<3){ console.log("true"); } else{ console.log("false"); } //output is true of above condition if(3>2>1){ console.log("true"); } else{ console.log("false"); } //output is false of above condition why is this happening both condition are true ?
6 ответов
+ 3
3>2 results in True which evalutes to 1 when compared with 1 so 1>1 is obviously false
+ 2
it might be because 3 > 2 = true which is also 1...and 1 > 1 is false. The > operation takes 2 arguments so the computer can't process the whole line the way you're seeing it.
+ 2
First:
(1<2<3)
This has two part.
1st : 1<2 = true , true=1,
2nd : so 1<3= true.
Finally the result is true.
Second:
3>2= true.true=1.
Than 1> 1. false.
Finally the result is false.
+ 1
Martin Taylor , am I right?
0
Thank you all for answering got the concept 👍