anyone know why setTimeout in this example just waits 600 milliseconds and them logs everything at once instead of logging one then in 600 milliseconds it logs the next? my thinking was that since foreach loops over each element in the array I can pause it each loop but that doesn't seem to work

Soo I didn't found the right explaination, let's go.

JavaScript is asynchronous. Which means a block of code will not wait for the previous to be achieved (if it doesn't needs it's value). In your case, setTimeout is a operation that can be time consuming, and JavaScript will not wait for the end of it before running next loop.

From time to time you need to wait for the execution of a block, best example whould be a web request, like an API call. To work this way js has Promises, which are basically a placeholder saying "I don't have the value yet, but wait for me, here it comes". Promises implement the method then() (old) or can be await. Either way, theses tools allows you to use JavaScript synchronously, and the next line will wait for the promise to resolve or fail.

MDN doc on asynchronous and Promise object.

/r/webdev Thread Link - i.redd.it