LOOP.
The wheels on the bus go round and round. 🙂 If you grew up in the United States you may know that song.
It’s about the wheels of a school bus. The bus is in motion so the wheels go round and round.
In computer programming, when something is happening over and over again, it is said to be in a loop.
The rocket below is stuck in a loop. NASA has lost control of the rocket and now it’s just going round and round.

PACMAN LOOP
PACMAN Loop is an idea inspired by PACMAN (a real game). In Pac Man loop, you have to move the hungry PacMan
all around the screen over and over again in a circle until you eat all the dots in the game.

While PacMan loop is not a real game, the concept of the game is real.
Computer languages have different commands for different types of loops.
Two of those commands are the “WHILE” loop and the “FOR” loop.
The While loop command is used to instruct the computer to do something while a condition is true.
Or to do something until a condition is met.
Below are examples of how loops are programmed using Python and JavaScript.
JavaScript
OPEN the JavaScript editor to test this “WHILE” loop in JavaScript
<script>let textjar = "";
let ijar = 0;
while (ijar < 10)
{
document.writeln ("The number is " + ijar);
ijar++;
}
document.writeln (“This is outside the while loop braces so it is not repeated”);</script>
The code above first uses the “Let” command to create 2 jars. One named textjar and the other ijar.
In JavaScript, the “Let” command lets you create a programming jar where you can store a value in.
Just like humans can create a cookie jar to store cookies in. A computer can create a text jar to stored text.
In our code above, the computer stores an empty text in the textjar. Meaning, no words/text is stored in the jar.let textjar = "";
The code above also creates a jar named “ijar” and stores the value of zero in it.let ijar = 0;
Next the ‘while” command initiates a loop. Everything inside the open and close braces of the while command
will be repeated over and over until the condition of the while command is met. In the code above, the condition
that must be met is that the value stored in ijar must be less than 10. This means if the value stored in ijar becomes 10 or greater than 10, the loop stops.
while (ijar < 10)
The while command has braces to specify what runs in the loop. Everything inside the braces are affected by the loop.
But anything outside of the braces is not affected by the loop. There are 2 instructions within the braces of the while loop.
{
document.writeln ("The number is " + ijar);
ijar++;
}
document.writeln ("The number is " + ijar);
This command tells the computer to write the following text on the screen "The number is "
The command also wants the value of ijar to be written to the screen.ijar++;
This command tells the computer to increment the value stored in ijar. The value will be increased by 1.
So if the value in the jar is 5, the value would become 6.

Pac-Man,[a] originally called Puck Man in Japan, is a 1980 mazeaction video game developed and released by Namco for arcades. In North America, the game was released by Midway Manufacturing as part of its licensing agreement with Namco America. The player controls Pac-Man, who must eat all the dots inside an enclosed maze while avoiding four colored ghosts. Eating large flashing dots called “Power Pellets” causes the ghosts to temporarily turn blue, allowing Pac-Man to eat them for bonus points.