Use [] to find tag! Example: [flutter, javascript]

Javascript made easy
Javascript made easy

Chapter 6

While

remove_red_eye 3144 Times
spellcheck 208 Words, 978 Characters
*Note: this book is still ongoing until it has a finished label.

The while loop is a very rarely used loop. Because this loop only has a condition where the loop  can be run alone, whereas a more frequently used loop requires something to cause the condition  stop.


Flow Chart



Code Example


void main(){
   var i = 1;
   while(i<=5){
     print(i);
     i++;
   }
}

the result is: 

1
2
3
4
5


Code Explanation


1. is a supporting variable to look for stop conditions.

2. loop condition, if i is less than or equal to 5 then the loop is still running.

3. display data i.

4. increment i.


Of the 4 stages, the loop condition on while is at point number 2.

By the way, for those of you who really like programming, don't forget to keep following this website, okay? There will be a book feature later, where this feature will make it easier for us to learn in silence. Thank you silent learners! keep the spirit Okay!

Content Navigation