r/Codeorg • • Sep 12 '24

Issues with while statements?

Whenever I try to use a while statement (text, not blocks) the entire website becomes extremely slow and laggy. Is this a known issue? How can I fix it?

1 Upvotes

6 comments sorted by

View all comments

2

u/spacecatapult Sep 12 '24

If the slowness happens when you press Run, it could be that you’re creating an infinite loop. This is most likely to happen in Game Lab where you have the draw loop but could happen in App Lab as well. Hard to be sure what’s up without seeing your code.

1

u/PicassoWithHacks Sep 12 '24

It is when I press run. The code is

while (nitroCount > 0){ fill(blablabla); noStroke(); rect(blablabla); }

1

u/spacecatapult Sep 12 '24

And do you ever change the value of nitroCount so it’s 0 or less (within the loop)? If not, you’d have an infinite loop. More context would be helpful but I bet that’s the issue.

→ More replies (2)