Now our programs become intelligent thanks to the concept of conditional logic.
Conditional logic is when we evalutate whether an expression is True or False. Take for example a night club. When we ask for the users age we need to determine if the user is 18 years or over.
We test the expression
userAge >= 18 and if it's true then the person is old enough. Else it's false
then the person is too young.
What about a count down from 10 to 0. While count > 0 the while condition is true so the loop keeps looping. The While loop is broken when the condition becomes false.
The For loop is good when you know how many times you wish to loop.
For loops can use the Step keyword as well. In this example the loop iterates in Steps of -1.
Loops are a type of branching. Instead the program being read 1 line after the other, the loop causes the program to branch back to the head of the loop until the loop is broken.
There are also nested loops, that's when you have a loop inside a loop. I discuss these later.