Focus video player for keyboard shortcuts
Auto
- 720p
- 540p
- 360p
1.00x
cc
- 0.50x
- 0.75x
- 1.00x
- 1.25x
- 1.50x
- 1.75x
- 2.00x
We hope you enjoyed this lesson.
Cool lesson, huh? Share it with your friends
About this lesson
How to use the While loop.
Exercise files
Download this lesson’s related exercise files.
While Loops58.8 KB While Loops - Solution
59.2 KB
Quick reference
While Loops
In this video we'll learn about while loops.
When to use
You can often use any sort of loop you like, while loops are pretty easy to use though.
Instructions
The general format of a while loop is:
while (condition) {
//do something;
}
Be sure to set a variable as a counter, and increment the counter inside the loop so you don't get an infinite loop!
Hints & tips
- While loops are used to loop "while" something is true.
Lesson notes are only available for subscribers.