cthunda303. Once you use setTimeout(), in pratice you can hardly ever have 0 milliseconds. Due to admin reasons the time is always approximate, so 0 does not really mean zero precisely.
I noticed this too! So I put the following what-happens-if code into main.js and also in Visual Code.
When I run the script from within codecademy, it takes about 4 seconds before any lines of output are printed. When I run from VisualCode, the first two lines immediately print to the console. I suspect running from Visual Code is more accurate. I am not sure what codecademy does to invoke a script when you hit the Run button
console.log(‘First message!’);
setTimeout(() => {
console.log(‘This message will run third…’);
}, 3000);
setTimeout(() => {
console.log(‘This message will run fourth…’);
}, 4000);
I came here wondering the same thing. It seems to be an issue with Codecademy. When I test it in a text editor and run it on the command line (Debian 10), the messages without setTimeout print immediately.
Actually, I don’t see that effect. The code behaves as expected either in VSC or Codeacademy . the console.log should run last because is being putting in a queue using “setTimeout”.
Same, there is a difference. I suspect though that the one person who doesn’t and those of us who do are using different browsers (I am using Chrome). Just speculation, I’m not qualified enough to know for certain. Wish though someone who clearly is qualified can add to this thread.
So I am confused with this setting the setTimeout to cero and still showing up at last. So conclusion even if you put time to cero still will show up last right? And the reason is because you included setTimeout? The system by default will put the console.log() at the end of the queue. correct?