> For the complete documentation index, see [llms.txt](https://solaartw.gitbook.io/developer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://solaartw.gitbook.io/developer/documentation/utilities/redscript/reference-sheets/language-features/loops.md).

# Loops

REDscript supports two kinds of loops: while and for..in loops.

## while <a href="#while" id="while"></a>

The `while` statement works the same way it does in most languages. It allows you to execute a block of code multiple times based on a conditional expression.

```
let i = 0;
let array = ["a", "b", "c"];

while i < ArraySize(array) {
  let elem = array[i];
  Log(elem);
  i += 1;
}
// will log a, b and c
```

## for..in <a href="#for..in" id="for..in"></a>

The `for..in` loop allows you to iterate over all elements of an array.

```
let array = ["a", "b", "c"];

for elem in array {
  Log(elem);
}
// will log a, b and c
```
