Loops are used when you want to run your code multiple times. There are different types of loops you can use, including for, while, and do-while. Each of these loops is utilized for different purposes. For the for loop function, you would want to use it when you run the same code over again but with a different value. While loops are good when you want to perform a task over again when there is a condition that needs to be met. Do-while loops are good to use when you know you need to perform the loop at least once but aren’t entirely sure how many times that loop will need to be performed. There are three parts of a loop, the keyword that starts the loop, the condition, and the keyword that ends the loop. Each loop looks a little different as well.
The for loop looks a bit like this:
Let num = 0
For ( let number =1, number <5; number++)
We worked on this in our last coding assignment as well.
The while loop looks a bit like:
Let num=0
While (num > 3){
alert ();
Count++
}
And the do-while loop will look a bit like:
Let count = 0;
Do{
alert();
Count++;
} while (count<7);
Hi Kristina! The way you explained loops was done extremely well! I definitely struggled with loops when reading the book, but I have a much better understanding after reading your blog post!
Hi Kristina! I thought your analysis on loops was great and your examples of loops were also very good. I struggled with using loops here and there during our assignments so I appreciate your post!