The Infinite Loop, and How to Avoid It
Every while loop needs three things. Miss any one and it runs forever:
1. A variable initialized before the loop
2. A condition that can eventually become false
3. Something inside the loop that moves toward that false
Forget step 3 and the condition never changes. The program hangs.
✦ You are protected here
The Sankofa sandbox stops runaway JavaScript after four seconds and tells you what happened, so you can experiment without fear. On your own machine there's no such net, Ctrl+C is how you stop it. Learning to spot the missing update is the real skill.
Mark this lesson complete
Signed in, your progress follows you to every device.