"While" command is bugged
Closed this issue · 2 comments
Hello! I am a javascript beginner. I tried playing around with the "while" command and I don't think that's how it should of worked in this situation.. here's the code:
"var x=4;
while(x>0)
{
console.log (x);
x--;
}"
The result I get is:
"4
3
1
2
1"
There is a random "1" on the third number and it remains there no matter how much I increase the x. If I write the "x--;" BEFORE the console.log command the problem is resolved but you still need it after console.log sometimes.
@Robertt12345 have you compared this output to other environments?
If the issue is related to the order of the output, please take a look here: #497
@Robertt12345 the results appear to be consistent with the Chrome console and Node Repl.
The 1
value is the final value of x
after the loop has finished iterating.
Closing as this appears to not be an issue.