#how do i use a while loop without stopping the code
17 messages · Page 1 of 1 (latest)
The question is so incomplete that it is impossible to answer. Can you give an example of when a while loop stops code?
The part that requires clarification is the meaning of "stopping the code". This does not have a specific definite meaning and has many possible interpretations, far more than you probably realize if you are a beginner.
like
while loops just keep going in a loop (its in the name). now i put it in the beginning and the rest of the code dosent run
is there a way to get around this?
This is the result of an infinite loop. If the loop has a definite end point, then the rest of the code eventually will run.
yeah
but i want the loop to run WITH the rest of the code instead of it stopping the code
while the loop is still running
Javascript normally runs in a single thread. You can sometimes fake parallelism with async code, but the only real way to run code in parallel is using web workers. This is actually an advanced topic. Whatever you are trying to do very likely does not require this, even if you might think it does.
i can try web workers
What are you actually trying to make happen?
im trying to make a discord bot that sends messages randomly after a bit of time, and im also having commands and all of that
You do not need web workers for that. I recommend learning about callbacks instead.