Control Flows : Loops

for loop

for(int i=0; i< 10; i++){
    print(i);
}
var numbers = [1,2,3];
// for-in loop for lists
for(var number in numbers){
    print(number);
}

do-while loop

do {
  workHard();
} while (!dreamsAchieved);

do-while loop verifies the condition after the execution of the statements inside the loop

while loop

while (!dreamsAchieved) {
  workHard();
}

while loop check condition before iteration of the loop

Comments