A for loop is used when you want to do something a specific number of times. They’re often used if you need to perform some operation on every member of an array. A for each loop is pretty similar to a for loop, just with slightly different a syntax.
A while loop is used when you need the loop to keep executing the loop and unknown number of times until some condition is met. A do while loop is similar to a while loop but is guaranteed to execute at least once.
Latest Answers