while
While is another type of loop. While will run a block of code over and over until a condition becomes false. Syntax:
while(condition) { // run code }
Here's a working example:
while(i < var2) i=i+1;