#how do i use a while loop without stopping the code

17 messages · Page 1 of 1 (latest)

modest flare
#

im kinda new to javascript so

ionic lintel
#

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.

modest flare
#

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?

ionic lintel
modest flare
#

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

ionic lintel
# modest flare 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.

modest flare
#

i can try web workers

ionic lintel
modest flare
#

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

ionic lintel
modest flare
#

ok

#

is callbacks basically return