Assignment 021
While Loops
Another useful programming structure is the while loop.
- The while loop requires one parameter, just the condition.
- The condition is used to determine how many times to run the loop. The loop will continue to run while the condition is true. Once the condition is no longer true, the next line of JavaScript code will execute.
- The while loop will only run if the condition is true.
The for loop and the while loop are essentially the same. However, the while loop doesn't have to use variables to count. Intstead it keeps running until a condition is no longer true.