Many computer programs—particularly games—include activity that's constant: a ball is always moving; a steady stream of bad guys are coming at you; a target moves back and forth across the screen. In programming terms, any code that's supposed to keep running over and over is contained inside of a loop.
There are many different kinds of loops. Some never stop. Some loop a prescribed number of times. Some loop until a particular condition is met. Some loop only while a particular condition is true. Each has its purpose.
Bitsbox's built-in loop function makes it easier to write looping code. Any code inside a loop function runs 20 times per second. Here's a program that endlessly draws apples on the screen.
Bitsbox's repeat command is another kind of loop; it loops a set number of times by calling a custom function. This program draws random oranges on the screen by calling the fruit() function 10 times.
Javascript has many other kinds of loops that are handy, but maybe a little harder to understand. Here's how one could draw 10 limes with a while loop:
Here's how one could draw 10 pears with a for loop:
All of the above achieve the same goal. As a beginning coder, it can be frustrating to see more than one way of doing things, but as you experiment and play you'll figure out which ways are your favorite.