+ 1
What is the output ? Can anyone explain the process of this code?
<script> var a=10, b=20,c=30; if(c>b>a){ document.write('1'); }else { document.write ('2'); } </script>
2 Réponses
+ 2
Operator precedence is left to right, so (30 > 20 > 10) is interpreted as ((30 > 20) > 10) which produces (true > 10) and since true is counted as 1 the expression returns False.
Thus, the else block is executed and the number 2 is printed.
+ 2
Ohk Thank you 😊