I'm confused about Loops


#1

For my computing homework, i have to visit the code academy page on while loops and for loops and complete some tasks. I then have to print one while loop and one for loop out. I am really unsure how to do this and i would like some help please.

Isabel Heneghan


#2

Here's the syntax for while and for loops:

For:
for (some conditions) {
// do something;
}

While:
while (some conditions) {
//do something;
}

A do-while is basically a while loop turned around, so it runs the code first, then checks if the conditions are true:

Do-While:
do {
//some stuff;
} while (some conditions);

Hope that helped! :smile: