34,333
edits
Changes
→JavaScript ''while'' loops
The ''for'' loop described above works well when you know how many times a particular task needs to be repeated. Clearly there will often be instances where something needs to be repeated until a certain condition is met, with no way of knowing how many repetitions are going to be needed to meet that criteria. To address this need JavaScript provides the ''while'' loop. In essense the ''while'' loop repeats a set of tasks until a specified condition is met. The ''while'' loop syntax is as follows:
<pre>
while (''condition'')
{