I just started learning JS, before this (as now) C # codeu. For me, JS implicit typing is just awful! There was a specific case, the code does not work successfully.
if (step + direction < 0) { document.writeln("outdown"); } else { step += direction; document.writeln(step); }
At the same time step at the beginning of execution 0 , and direction -1 . Instead of the inscription outdown displays " 0-1 ". I understand that this is due to the fact that one variable is not an int, but a string. How to fix it, I do not know.
step=0
anddirection=-1
, then the output is exactlyoutdown
. You obviously do not say something. For example, the fact thatstep
anddirection
not really numbers, but strings - andreymal