# Creating Loops

> Learn how to implement dynamic loops to collect repeated information from users in your chatbot.

Source: https://edesy.in/docs/zapbot/guides/loops

*Video tutorial available in the Zapbot dashboard*

In this guide, we demonstrate how to implement a dynamic loop to collect guest names for a restaurant reservation chatbot.

## Overview

We walk through setting up the chatbot to request the number of guests, and then, using JavaScript, create a list based on this number.

## How It Works

1. **Ask for count**: Request the number of guests from the user
2. **Create a list**: Use the 'Shift' set variable value to iterate through this list
3. **Collect information**: Store each guest's name through the loop

## Implementation

Despite the lack of a specific loop block in the platform, you can create loop-like behavior through custom code using the [Set Variable block](https://edesy.in/docs/zapbot/logic/set-variable).

### Key Concepts

- Use JavaScript in the Set Variable block to manage iteration
- The 'Shift' operation removes and returns the first element of an array
- Connect blocks to create the looping behavior
- Use conditions to check when the loop should end

## Example: Guest Name Collection

1. Ask "How many guests will be attending?"
2. Store the number in a variable
3. Create an array with that many empty slots
4. Loop through each slot, asking for a guest name
5. Store all names in a results array
