Week 4 Day 3 - February 26, 2025
Control Flow: Loops
Today we learned about the different types of loops. These included:
- While Loop - this repeatedly runs a block of code as long as the specified condition remains true.
- for Loop - This loops has 3 specified conditions and is written like for {iterator; condition; iteration} {}
- Do while - This loop will run through once and then run through the while look as long as the specified condition remains true.
The lab for today included creating a guessing number game. It involved generating a random number between 0 and 100 and then using a while loop to submit our answers. The condition for the while loop is the incorrect guess. Different alerts pop up if the guess is too high or too low. When the player finally submits the correct answer, the while loop exits and the congratualtion animation goes off.