> For the complete documentation index, see [llms.txt](https://solstep.gitbook.io/solidity-steps/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://solstep.gitbook.io/solidity-steps/step-2/13-while-loop.md).

# 13: While Loop

A while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition. The while loop can be thought of as a repeating if statement.

**Syntax**:

```solidity
while (condition) {  
    // code block to be executed 
}
```

**Example**:

```solidity
let i = 0; 
while (i < 10) {  
    console.log(i); // you can test by hardhat console log 
    i++;
}
```

*Output*`: 0123456789`

*That's it for the lesson 13! In the next lesson, Do While*
