How do I run a nested loop synchronously?
How do I run a nested loop synchronously? I'm writing a simple script that prints text to the screen one character at a time. I'm making it so that the function (which I've called slowPrint ) can receive an Array of Strings. Each element in the Array represents a message. slowPrint This is the code I have so far: However, I am not getting the expected output. I suspect this is in part to the asynchronous nature of the code, though I don't have a full and clear understanding of what's happening and how to fix it. To begin with, the <br /> tags are being printed before any of the messages, which tells me that the outer loop is finishing before the nested one even starts. <br /> When the nested loops does begin, however, each string in the array is being printed one second apart, but in their entirety rather than character by character . What am I missing? Additionally, can someone please explain the following behavior of the setTimeout method? setTimeout...
