How is this an infinite loop

This question regards the JavaScript Back-end Development course -> Introduction to Node.js -> Intro to Node.js quiz -> Question 4

How is this an infinite loop?

Thanks

James

There is no break condition or change of state within the loop. It will run indefinitely.

Does the setTimeout() function not change shouldContinue to false after 2 seconds?

It would but you’re still running blocking code.
What you’d have to do is use a loop that re-schedules itself

1 Like