lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2k stars 43 forks source link

"While" command is bugged #579

Closed Robertt12345 closed 9 months ago

Robertt12345 commented 9 months ago

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.

lukehaas commented 9 months ago

@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: https://github.com/lukehaas/RunJS/issues/497

lukehaas commented 9 months ago

@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.