The while loop checks a condition before each iteration. If the condition is true, the loop body runs. If false, the loop exits. You use while when you don't know how many iterations you need upfront.
The loop continues until some event changes the condition to false. While loops are flexible but require you to manually update variables inside the loop. Forgetting to update can cause infinite loops.