4 ms·
I don't understand. The prompt is given as 4 lines: x = 1 x --> 0 which does not execute. And if I run them as two lines: x = 1 x --> 0 then the final o
by gitpusher 2y ago
I don't understand. The prompt is given as 4 lines:
x
= 1
x
--> 0
which does not execute. And if I run them as two lines:
x = 1
x --> 0
then the final output is `true`. `1` is only output during the initial assignment, which is hardly surprising
If i understand correctly, the reason i am getting `true` is because the second line gets parsed as two operations:
(x--) > 0
first a post-decrement operator (--) followed by a comparison (greater than). Since x = 1 it's greater than 0 (true), but afterward it's decremented so you'll get false if you run the same line again
- IainIreland 2y agoCopy and paste all four lines at once.
- gitpusher 2y agoOops, haha. Yes now i am getting `1` as the result. Thanks for the tip.
- ddalcino 2y agoYou can also use “shift + enter” to add a newline to your input, without telling the browser to take your input yet.