The difference between computers and humans is that computers can be told to perform the same task repeatedly without ever getting tired. To give such commands to a computer, you can use loops.
The While Loop
Example of a while loop script
When executed, the while loop above produces the following repetition:
Result of the while loop script
The Do While Loop
Do while is another technique for creating loops, with the main difference being that the conditional statement is placed at the bottom. If the previous code is converted to a do while loop, it looks like this:
Do while script
The output will appear as follows:
Do while used for repetition
Advertisement
Building a product that has to stay reliable? I help founders and product teams scope, build and scale web and mobile products, with testing built in from day one.
Book a call